任何人有任何用 vbscript 解析 xml 的例子吗?我有一个序列化为 XML 的 .NET 通用列表,我将其发送到经典的 asp 页面。我以为我可以使用 XMLDom,但是这些库似乎没有安装在服务器上,所以我正在寻找另一种解决方案。(收到“需要对象:documentElement”错误)
基本上,我以包含标题和主要文章部分的 xml 字符串的形式传递了大约 15 个对象的列表,我想遍历列表并打印出两者。
这是我在发现未安装 XMLDom 之前所拥有的:
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.loadXML(item)
Set objFirstChild = xmlDoc.documentElement.firstChild
Set objAttributes = objFirstChild.attributes
For Each Attr in objAttributes
Response.write(Attr.Headline & "<br>")
Response.write(Attr.Content & "<br>")
Next
Response.End
任何帮助表示赞赏 - 这些天我的 VBScript 很生疏!
编辑- 也尝试过,MSXML2.DOMDocument
但最终出现需要对象错误。
更新 - 应@ulluoink 的要求包含的示例 XML:
<?xml version="1.0" encoding="utf-8"?>
<articles>
<article>
<newsID>7</newsID>
<headline>This is headline 1</headline>
<content><![CDATA[<p>This is the start of the main content of the article</p><p>This is the next paragraph.</p> ]]></content>
<date>04/06/2013 00:00</date>
</article>
<article>
<newsID>7</newsID>
<headline>This is headline 2</headline>
<content><![CDATA[<p>This is the start of the main content of the article</p><p>This is the next paragraph.</p> ]]></content>
<date>04/06/2013 00:00</date>
</article>
<article>
<newsID>7</newsID>
<headline>This is headline 3</headline>
<content><![CDATA[<p>This is the start of the main content of the article</p><p>This is the next paragraph.</p> ]]></content>
<date>04/06/2013 00:00</date>
</article>
</articles>