var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var currNode;
var wsp;
xmlDoc.async = false;
xmlDoc.load("file:///D:/data/work/xml/test_sam.xml");
if (xmlDoc.parseError.errorCode != 0)
{
var myErr = xmlDoc.parseError;
WScript.Echo("You have error " + myErr.reason);
}
else
{
currNode = xmlDoc.documentElement;
WScript.Echo("root nodename " + currNode.nodeName);
// WScript.Echo("root attributes " + currNode.attributes(1).text);
prtattr(currNode, "");
// WScript.Echo("ff " + currNode.firstChild.firstChild.nodeName);
walkc(currNode, wsp="");
}
function walkc(node, wsp)
{
var child = node.firstChild;
var twsp = "";
while (child != null)
{
wsp = wsp + "-";
WScript.Echo(wsp + "nodename " + child.nodeName + ", nodevalue " + child.nodeTypeString);
prtattr(child, wsp);
walkc(child, wsp);
child = child.nextSibling;
twsp = ""
for (var i = 0; i < wsp.length-1; i++)
{
twsp = twsp + "-";
}
wsp = twsp;
}
}
function prtattr(node, wsp)
{
if (node.attributes != null)
{
for (var i = 0; i < node.attributes.length; i++)
{
WScript.Echo(wsp + "attr_name: " + node.attributes(i).name + ", \
attr_text: " + node.attributes(i).text);
}
}
}
2007年10月21日日曜日
XML(MSXML)とJScript
まだまだ作成途中。
2007年10月20日土曜日
登録:
コメント (Atom)