EDN Admin
Well-known member
Hello Folks,
Env=XP PRO, COM, MSXML v6, JScript/cscript
I am getting an error "testxml2.js(20, 1) Microsoft JScript runtime error: Object required " that happens when i try to access the <message> tag contents that is driving me crazy.
It errors on either of these two lines:
line # 20: WScript.Echo("Message access using pattern string=" + objXML.selectSingleNode("//response/status/message").text);//errors here<br/>
or
line # 30: ReturnMessage = colStatus[0].selectSingleNode("message").text;//errors here too
my simple xml file:
<br/>
<messsage>Missing/incorrect properties: Account end is before account start</messsage><br/>
</status><br/>
</response>
[/code]
my program:
Execution results:
<br/>
<messsage>Missing/incorrect properties: Account end is before account start</messsage><br/>
</status><br/>
</response><br/>
]
Code access using pattern string=1004<br/>
testxml2.js(20, 1) Microsoft JScript runtime error: Objet required
[/code]
Does anyone have a suggestion(s) - would apprecite it very much!!
Thanks!
<br/>
View the full article
Env=XP PRO, COM, MSXML v6, JScript/cscript
I am getting an error "testxml2.js(20, 1) Microsoft JScript runtime error: Object required " that happens when i try to access the <message> tag contents that is driving me crazy.
It errors on either of these two lines:
line # 20: WScript.Echo("Message access using pattern string=" + objXML.selectSingleNode("//response/status/message").text);//errors here<br/>
or
line # 30: ReturnMessage = colStatus[0].selectSingleNode("message").text;//errors here too
my simple xml file:
Code:
<?xml version="1.0"?><br/>
<response><br/>
<status><br/>
[code]1004
<messsage>Missing/incorrect properties: Account end is before account start</messsage><br/>
</status><br/>
</response>
[/code]
my program:
Code:
var objXML;<br/>
var thisMsg;
objXML = new ActiveXObject("Msxml2.DOMDocument.6.0");<br/>
objXML.load("testxml2.xml"); <br/>
//
if (objXML.parseError.errorCode != 0) { // did the XML results load properly?<br/>
thisMsg = "XML Failed to Load !! Error code: " + objXML.parseError.errorCode;<br/>
thisMsg += " Error reason: " + objXML.parseError.reason;<br/>
thisMsg += " Error line: " + objXML.parseError.line;<br/>
WScript.Echo(thisMsg);<br/>
WScript.Quit(1);<br/>
} //end-if<br/>
WScript.Echo("XML parseError test passed!");
WScript.Echo("Debug: XML obj xml [" + objXML.xml + "]n");//debug <br/>
//objXML.setProperty("SelectionLanguage", "XPath");<br/>
WScript.Echo("Code access using pattern string=" + objXML.selectSingleNode("//response/status/code").text);<br/>
WScript.Echo("Message access using pattern string=" + objXML.selectSingleNode("//response/status/message").text);//errors here
<br/>
var colResponse = objXML.getElementsByTagName("response");<br/>
var ReturnCode = "";<br/>
var ReturnMessage = "";<br/>
var colStatus = "";<br/>
if (colResponse.length > 0) {<br/>
colStatus = colResponse[0].getElementsByTagName("status");<br/>
ReturnCode = colStatus[0].selectSingleNode("code").text;<br/>
ReturnMessage = colStatus[0].selectSingleNode("message").text;//errors here too<br/>
}<br/>
else {<br/>
var responseText = objHttp.responseText;<br/>
thisMsg = "XML Response tag not found, aborting.n XML Dump [" + objXML.xml + "]n Text Dump [" + responseText + "]n";<br/>
WScript.Echo(thisMsg);<br/>
WScript.Quit(1);<br/>
} //end-if-else<br/>
WScript.Echo("Status=" + colStatus[0]);<br/>
WScript.Echo("Code=" + ReturnCode);<br/>
WScript.Echo("Details=" + ReturnMessage);
Code:
>cscript testxml2.js<br/>
Microsoft (R) Windows Script Host Version 5.7<br/>
Copyright (C) Microsoft Corporation. All rights reserved.
XML parseError test passed!<br/>
Debug: XML obj xml [<?xml version="1.0"?><br/>
<response><br/>
<status><br/>
[code]1004
<messsage>Missing/incorrect properties: Account end is before account start</messsage><br/>
</status><br/>
</response><br/>
]
Code access using pattern string=1004<br/>
testxml2.js(20, 1) Microsoft JScript runtime error: Objet required
[/code]
Does anyone have a suggestion(s) - would apprecite it very much!!
Thanks!
<br/>
View the full article