EN codeURIComponent或VB6逃生 [英] encodeURIComponent or Escape in VB6

查看:731
本文介绍了EN codeURIComponent或VB6逃生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有带codeURIComponent或Uri.EscapeDataString VBScript中,可以在传统的ASP页面中使用?

Is there a encodeURIComponent or Uri.EscapeDataString in VBScript that can be used in an classic ASP page?

我需要这个功能来生成可解析jQuery的XML。

I need this function to generate jQuery parseable XML.

Server.HTMLEn code没有做一个完整的工作。

Server.HTMLEncode does not do a complete job.

推荐答案

您可以只是自己逃避的人物,如果你想,按照这个环节,只有5:<一href=\"http://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents?rq=1\">What字符,我需要在XML文档中逃生?

You can just escape the characters yourself if you would like, according to this link, there are only five: What characters do I need to escape in XML documents?

因此​​,这样的事情应该工作:

Therefore, something like this should work:

//usage
EncodedXML = XMLEncode(MyDecodedXML)

//function
Function XMLEncode(str)
  XMLEncode = str
  If varType(XMLEncode) < 2 Exit Function
  XMLEncode = Replace(XMLEncode,Chr(34),"&quot;")
  XMLEncode = Replace(XMLEncode,"'","&apos;")
  XMLEncode = Replace(XMLEncode,"<","&lt;")
  XMLEncode = Replace(XMLEncode,">","&gt;")
  XMLEncode = Replace(XMLEncode,"&","&amp;")
End Function

否则,这通常是用VBS的 MSXML2.DOMDocument 对象来完成。文档可<一个href=\"http://social.technet.microsoft.com/Forums/scriptcenter/en-US/fcc6dcc3-716f-4dfe-b9e7-6559df4c5d60/MSXML2.DOMDocument\"相对=nofollow>此处。其使用的一个简单的例子是...

Otherwise, this is generally done using the MSXML2.DOMDocument object in VBS. Documentation is available here. A simple example of its use is ...

sFilePath = "D:\someplace\somefile.xml"
sXPath = "/SomeName/Someproperty"

Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLDoc.SetProperty "SelectionLanguage", "XPath"
oXMLDoc.Async = False
oXMLDoc.Load sFilePath
If (oXMLDoc.parseError.errorCode <> 0) Then
   Set oErr = oXMLDoc.ParseError
   WScript.Echo "Could not load file " & sFilePath _
              & " , error: " & oErr.Reason
   WScript.Quit
End If

Set objNames = oXMLDoc.DocumentElement.SelectNodes(sXPath)
For Each obj in objNames
  with obj
    wsh.echo .nodeName,  .getAttribute("name")
  end with
Next

这篇关于EN codeURIComponent或VB6逃生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆