XML Parsing issue

Hi ,
I am getting below error while i run service pub.xml:XMLStringtoNode ,passing an XML which is having " & " in values of one of the tags.


com.wm.lang.flow.WattEvaluationException: com.wm.lang.xml.WMDocumentException: [ISC.0042.9325] Element is missing end tag


Please suggest ,how can i handle such characters while XML parsing.
For the same kind of issue a service HTMLDecode is available,can i use it ?

Thanks

Sid,

I don’t think th e “&” is the issue. Make sure that there is an end tag for the “partnum” element.

12345

Mark

Error clearly mentions that the end tag is missing. Add the and reprocess it. That should work.
Thanks
Jay

Hi,
Its not a TAG issue.The XML i am passing is having the proper end TAG.

but its not parsing anything after “&”

Below is kind of value it has.

MS9501-&

And so it not reading the closing tag of the line

Please suggest ,what can be done.
Thanks

Is this the only “&” you are having in the XML string.

Sid;
It is an xml parser problem. It is not able to parse your & character. It is a special character issue. Need to use encoding and decoding special characters. Check if encoding input parameter set to UTF-8 helps. you can aslo use CDATA to ignore the content in tags. check other posts in the forum regarding special character issue.

Sid,

The escape characters like <, >, & etc… are changed to entity reference like <, >, & etc… when being parsed. So you are getting the correct value in MS9501-&. Just assign UTF-8 to ‘encoding’ and true to ‘isXML’ Service-in parameters of pub:xml:xmlStringToXMLNode.

Does any one has got the solution for the issue raised by sid, advise soemthing that can be done within webMethods to handle the malformed xml

Nothing can be reasonably done to handle malformed XML. It needs to be corrected at the source.

I dunno if Sid’s issue was resolved–he never posted the complete XML for analysis and didn’t indicate whether or not a solution was found.

If you’re facing similar issue, post the XML and someone may be able to determine what’s wrong and suggest a course of action.

Hi

I am facing the similar issue with pub.xml:queryXMLNode service, Tried even assigning UTF-8 to ‘encoding’ and true to ‘isXML’ Service-in parameters of pub.xml:xmlStringToXMLNode but still could not resolve the issue.

Below is the sample XML:

<?xml version="1.0"?>

British
Mahesh

Sr. Manager, System Eng. & Data Center

Error:
com.wm.lang.flow.WattEvaluationException: com.wm.lang.xml.WMDocumentException: [ISC.0042.9332] Malformed entity reference: & Data Center

Please try to help me in this regard.

You can try two options:

Write a custom java service to modify ‘&’ to ‘&’

For the service pub.xml:documentToXMLString, you’ll need to set the service input parameter ‘encode’ to true for the functionality desired.

See documentation "9-X_Integration_Server_Built-In_Services", for information about the input parameter ‘encode’ which states the following:

"String Optional. Flag indicating whether to HTML-encode the data. Set this parameter to true if your XML data contains special characters, including the following:

< > & " ’

Set to:

true - to HTML-encode the data.

For example, the string expression 5 < 6 would be converted to 5 < 6, which is valid.

false - to not HTML-encode the data. This is the default.
For example, the string expression 5 < 6 would be converted to 5 < 6, which is invalid."

Site set the input parameter ‘encode’, for service pub.xml:documentToXMLString, to ‘true’ and problem resolved.

The ‘&’ is now converted correctly to "&.

Hi Mahesh S,

Are you generating XML string using built in service ? Try to use XML data as attached

Thanks,
Yogesh
Capture.PNG