vbscript で xml を解析する例はありますか? 従来の ASP ページに送信する XML にシリアル化された .NET ジェネリック リストがあります。XMLDomが使えると思ったのですが、サーバーにライブラリがインストールされていないようで、別の解決策を探しています。(「Object Required: 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>