Unable to Parse ampersand while converting XML String to Document

Hello,
I have an XML string as Input to a service.
The XML contains a string which has ‘&’ [ampersand] in it.
Example: Engineering & Management Services

I am converting this XML String to Node (using pub.xml:xmlStringToXMLNode) and then to Document ( using pub.xml:xmlNodeToDocument).

While converting to Document, I am getting the below error:

com.wm.app.b2b.server.ServiceException: [ISC.0042.9332] Malformed entity reference: & Management Services


I have tried using encoding = UTF-8 and UTF-16 but got the same results.

For debugging purpose, when I change the “&” to “&” in the source XML string then it works perfectly, but as a solution this cannot be taken, as no change in source XML is allowed.

Any suggestion for this solution is really appreciated.

Thanks

Hi Soumodip,
In the xsd of this xml for this particular field you can define accepted special character. Once you define then it should not throw this error.

Regards,
Vikas

Hi Soumodip,

The above scenario is an invalid xml character according to XML 1.0 Spec, so if possible tell the source to send with a valid html character(&amp as you mentioned).
If not set the below watt property to disable validation.
watt.server.xml.enforceEntityRef=false

My $.02,
Niteesh

The source MUST change the XML to convert & (and other specific characters used for markup) to the proper entity character. E.g. change & and &. It is not valid XML otherwise and there is nothing that you should do on your side to accomodate that invalid XML.

I would strongly advise against using this setting. You should tell the source that they MUST produce valid XML.

Thanks All for your valuable feedback & suggestions.

Hi All,

I m also facing the same error in my code .Source is sending the XML with &.
As per nitesh i set the below property,

watt.server.xml.enforceEntityRef=false

But still getting the same error.Source is not able to correct this.Since webMethods needs to allow this special charaters in the xml.Any one please suggest.

Pass the xml string to find and replace ‘&’ to ‘amp’ ‘and’

Hi Mahesh,

Thanks for your info.

Is it possible to accept the special characters without changing the source XML format?

Regards,
Sakthi

According to me watt.server.xml.enforceEntityRef=false setting should have fixed your problem. Did you reboot the Is after giving this setting.

Option 3: Use the pub.string:HTMLEncode pass your input xml string to this service first and then process it further.

Yes restarted.But still facing same issue…

yea.i tried that,but it looks like whole xml format got changed.i m getting the error while converting XML to node service ,since it is not able to recognize the ‘&’ .so it is failing.

Option 3: Use the pub.string:HTMLEncode pass your input xml string to this service first and then process it further.

Let me know your results.

Attach your xml file I will see that is the issue. Talk to you soon.

Hi Mahesh,

Here is the sample XML for you,

Arun & Kumar Suman & Kumar

Error occuring when it tries to convert XML node to document .

and Currently we are using the Version 7.1.2

Regards,
Sakthi

You have not read and understood my earlier post :lol:

Map the xml data to string replace service and replace & with

& amp ; (no spaces)

Map the value of string replace to xml string to node and then node to document.

Or before passing your xml data to xml string to node repalce & with amp or and.

Hi Mahesh,

I already did that ,it is passing the node to document service without any error,But looks like document getting generated as empty and also it is not an understandable format,
and as you said we unable to replace the & with & as source is only sending the XML data with ‘&’

However we have to accept special character & from source in any case without changing the XML.

how do you receive the xml string in webMethods?

I have to check other alternate options and let you know. I remember doing this in the past projects. Stay tuned!

Hi Mahesh,

we are receiving the XML via MQ.

Regards,
Sakthi