XML-110018 Error while parsing XML string | Community
Skip to main content
Level 2
June 8, 2023
Solved

XML-110018 Error while parsing XML string

  • June 8, 2023
  • 3 replies
  • 1862 views

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];
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by isahore

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

3 replies

LakshmiPravallika
Community Advisor
Community Advisor
June 8, 2023

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.

 

 

 

Level 2
June 8, 2023

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.

 

adobechat
Level 5
June 8, 2023

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

 

 

isahore
Community Advisor
isahoreCommunity AdvisorAccepted solution
Community Advisor
June 12, 2023

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

jjwatson79
Level 2
June 12, 2023

@isahore has addressed a few issues in that reply.

  1. When executing your query, you will build a "schema" collection, rather than a "data" collection, which the original code assumes
  2. The XML declaration is not always necessary, but is best practice.
  3. The toXMLString is not necessary, but not problematic in this case. You can just use the toString function, because it will be constructed as an xml object anyway, because you're using the DOMDocument.fromXMLString function. Either approach works here, but I suspect there is less processing required just using toString rather than toXMLString.