がドキュメントの上にある場合、JScript を使用した Windows Script Host での XPath 式の評価に問題があります。DOCTYPE 解析を削除しても壊れません。これは、xml の解析と読み込みに使用しているコードのサンプルです。DOCTYPE宣言を削除せずにこの種のXMLを解析する方法はありますか?
処理中に DOCTYPE を削除したくありません。解決策は、正規表現を使用して DOCTYPE を削除すること
<!DOCTYPE.*?>/gm;
ですが、そのような解決策は必要ありません。
var XmlDocument;
try {
XmlDocument = new ActiveXObject("msxml2.DOMDocument.6.0");
XmlDocument.async = false;
XmlDocument.resolveExternals = false;
XmlDocument.validateOnParse = false;
} catch(e) {
if(debug == true)
WScript.echo("***ERROR while creating DOM Object: " + e.description);
}
// Load an XML file into the DOM instance
try {
XmlDocument.load(filePath);
} catch(e) {
if(debug == true)
WScript.echo("***ERROR LOADING FILE: " + e.description);
}
var Node;
try {
Node = XmlDocument.selectSingleNode("//metadata/url");
} catch(e) {
if(debug == true)
WScript.echo("***ERROR RESOLVING NODE: " + e.description);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rightinclude SYSTEM "http://localhost/iw/aa.dtd">
<a>
<b>
<c>/someurl.html</c>
</b>
</a>