Parsing XML that has &

  • 11 November 2005
  • 2 replies
  • 1 view

Badge +1

We are having a problem parsing XML that has an "&" contained within one of the elements.

We are receiving an error
"An error occurred while parsing EntityName"
when the following code is run because one of the elements has an "&"

System.Int32 complaintID = Convert.ToInt32(SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields["complaint"].Value,"newComplaint/newID"));

This is not the element that has the "&", so we are assuming it tries to parse the whole XML string and complains.

is there any way of changing any "&" in the XML fields in order that this may not happen.


2 replies

Badge +1
We're having sort of the same issue. When creating items on sharepoint lists where the values contains "&" K2 inserts & into the item... We need to find a work around for this...
Badge +1
K2.net follows the conventions for well-formed XML. This means that even element values are evaluated remember that as the following characters are frequently used to define an XML document it is advisable to replace them with their entitity reference:
- & replaces the ampersand (&) character
- &lt; replaces the less than (<) character
- &gt; replaces the greater than (>) character
- &apos; replaces the single quote or apostrophe (') character
- &quot; replaces the double quote (") character

Hope this helps a little
Lori

Reply