Hi,
I'm trying to read a variable and I get this error "XML-110018 Error while parsing XML string" here is my code :
var query = xtk.queryDef.create(
<queryDef schema="xtk:schema" operation="select" lineCount="1">
<select>
<node expr="data" alias="data"/>
</select>
<where>
<condition expr={"@namespace='nms'"}/>
<condition expr={"@name='recipient'"}/>
</where>
</queryDef>);
var queryResult = query.ExecuteQuery(); // START QUERy
logInfo("Data type :"+ typeof queryResult[0].data);
var xml = new DOMDocument.fromXMLString(queryResult[0].data.toXMLString());
var tag = xml.getElementsByTagName("attribute")[0];
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @AnasSpir05,
Change your line to this:
var xml = DOMDocument.fromXMLString("<?xml version='1.0'?> " + queryResult.schema[0].toString());
This will populate your "tag" variable without error.
Thanks,
Ishan
Hi @AnasSpir05 ,
Please check the below part given in your code highlighted in yellow colour:
It should be having "@data "instead of "data" . Please cross check this and run it again.
Regards,
Pravallika.
Views
Replies
Total Likes
hi @LakshmiPravallika ,
thank you for your reply but it still doesn't work and in the data schema it has the type memo with the tag element not attribute.
Views
Replies
Total Likes
Hi @AnasSpir05 ,
Instead of trying to call the variables directly(replace last 3 lines with below), try using for each loop and print them as below:
for each (var row in queryResult)
{
logInfo("data printing "+row.data);
}
Views
Replies
Total Likes
Hi,
Need more context but try this
var query = xtk.queryDef.create(
<queryDef schema="xtk:schema" operation="select" lineCount="1">
<select>
<node expr="data" alias="data"/>
</select>
<where>
<condition expr="@namespace='nms'"/>
<condition expr="@name='recipient'"/>
</where>
</queryDef>
);
var queryResult = query.ExecuteQuery(); // START QUERY
logInfo("Data type :"+ typeof queryResult[0].data);
var xmlString = queryResult[0].data.toXMLString();
logInfo("XML String : " + xmlString);
var xml = new DOMDocument.fromXMLString(xmlString);
var tag = xml.getElementsByTagName("attribute")[0];
Hope it works.
Thanks
Madhan
Views
Replies
Total Likes
Hi @AnasSpir05,
Change your line to this:
var xml = DOMDocument.fromXMLString("<?xml version='1.0'?> " + queryResult.schema[0].toString());
This will populate your "tag" variable without error.
Thanks,
Ishan
@isahore has addressed a few issues in that reply.
Views
Replies
Total Likes
Thank you for your help finaly it's work !
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies