anatar02
14 years agoContributor
[C#] Getting [object Error]error while executing the second node of xml
[C#] Getting [object Error]error while executing the second node of xml
Hi All,
I
am using below setup of C# code to retrieving the values by node and
its working fine with a single node, if I am retrieving only one node in
a script, then its working well and fine but the same time its giving
[object Error] error message when I wanted to retrieve more than one
nodes a script. I have done the research on the failure but I could not
find the root cast in this, so can someone please help me with this.
Sample sample is attached.
Code :-
function doGetxmlvaluebyNode(filepath, testdata)
{
var Doc, s, Nodes, Node;
Doc = Sys["OleObject"]("Msxml2.DOMDocument.4.0");
Doc["async"] = false;
Doc["load"](filepath);
// Use the XPath expression to obtain the needed node
NameNode = Doc["selectSingleNode"]("//TestData/Data[Name='"+testdata+"']/Value");
ValueNode = Doc["selectSingleNode"]("//TestData/Data[Name='"+testdata+"']/Value");
doGetxmlvaluebyNode=(ValueNode["text"])
Doc[null];
return doGetxmlvaluebyNode;
}
Sample Xml
<TestData>
<Data>
<Name>executionMode</Name>
<Value>debug</Value>
</Data>
<Data>
<Name>Sub_Environment</Name>
<Value>LastName</Value>
</Data>
<Data>
<Name>Company</Name>
<Value>test</Value>
</Data>
</TestData>
Please help me on this.
//USEUNIT Utility
function test ()
{
var filePath= "C:\\Data.xml";
var executionMode=Utility["doGetxmlvaluebyNode"](filePath,"executionMode");
Log["Message"](executionMode);
Note :-
Till here its working fine and its retrieving the expected node successfully. its throwing an error below code
var Sub_Environment=Utility["doGetxmlvaluebyNode"](filePath,"Sub_Environment");
Log["Message"](Sub_Environment);
}
Hi All,
I
am using below setup of C# code to retrieving the values by node and
its working fine with a single node, if I am retrieving only one node in
a script, then its working well and fine but the same time its giving
[object Error] error message when I wanted to retrieve more than one
nodes a script. I have done the research on the failure but I could not
find the root cast in this, so can someone please help me with this.
Sample sample is attached.
Code :-
function doGetxmlvaluebyNode(filepath, testdata)
{
var Doc, s, Nodes, Node;
Doc = Sys["OleObject"]("Msxml2.DOMDocument.4.0");
Doc["async"] = false;
Doc["load"](filepath);
// Use the XPath expression to obtain the needed node
NameNode = Doc["selectSingleNode"]("//TestData/Data[Name='"+testdata+"']/Value");
ValueNode = Doc["selectSingleNode"]("//TestData/Data[Name='"+testdata+"']/Value");
doGetxmlvaluebyNode=(ValueNode["text"])
Doc[null];
return doGetxmlvaluebyNode;
}
Sample Xml
<TestData>
<Data>
<Name>executionMode</Name>
<Value>debug</Value>
</Data>
<Data>
<Name>Sub_Environment</Name>
<Value>LastName</Value>
</Data>
<Data>
<Name>Company</Name>
<Value>test</Value>
</Data>
</TestData>
Please help me on this.
//USEUNIT Utility
function test ()
{
var filePath= "C:\\Data.xml";
var executionMode=Utility["doGetxmlvaluebyNode"](filePath,"executionMode");
Log["Message"](executionMode);
Note :-
Till here its working fine and its retrieving the expected node successfully. its throwing an error below code
var Sub_Environment=Utility["doGetxmlvaluebyNode"](filePath,"Sub_Environment");
Log["Message"](Sub_Environment);
}