vbs changes < to> to > when importing file contents

后端 未结 2 746
死守一世寂寞
死守一世寂寞 2021-01-25 22:12

I have absolutly no idea when it comes to VBScript so I was quite happy when I frankensteined two simple code snippets found online to insert the entire contents of a text file

2条回答
  •  悲&欢浪女
    2021-01-25 22:50

    A CDATA section allows < and >:

    CDATA sections allow developers to include the markup characters <, >, and & within element content without using character or entity references. Scripts, style sheets, program code, and sample XML code are frequently contained in CDATA sections.

    (Docs)

    Code:

      Dim oXML : Set oXML = CreateObject("Msxml2.DOMDocument")
      Set oXML.documentElement = oXML.createElement("a")
      Dim nd
      Set nd = oXML.createElement("b")
      nd.appendChild oXML.createTextNode("<>")
      oXML.documentElement.appendChild nd
      Set nd = oXML.createElement("c")
      nd.appendChild oXML.createCDATASection("<>")
      oXML.documentElement.appendChild nd
    

    output:

    <>]]>
    

提交回复
热议问题