Parsing an XML document that includes special characters such as '&'.

Parsing an XML document that includes special characters such as '&'.

book

Article ID: KB0091547

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks -
Not Applicable -

Description

Resolution:
Description:
============
While parsing an XML document, elements that include the character '&', will get generate invalid data and fail to parse. What is the best approach for resolving this issue so as to validate an XML document?

Resolution:
==========
According to the XML1.0 specifications, the & (ampersand) character is treated as a special character. If you place a character like "&" inside an XML element, the parser will generate an error. If you want to the include an ampersand sign in XML, you must either use an entity reference (&) or include the string containing the ‘&’ in the CDATA section.

Refer Section 2.4 of the following for detailed information.

http://www.w3.org/TR/REC-xml/#syntax

Two examples are attached for your reference. Example #1 (Filename: xml-amp-issue-num1.dat) uses the entity reference (&) for the ‘&’ character and example #2 (Filename: bw-xml-amp-CDATA-num2.rar) will use the CDATA section.

Issue/Introduction

Parsing an XML document that includes special characters such as '&'.

Attachments

Parsing an XML document that includes special characters such as '&'. get_app
Parsing an XML document that includes special characters such as '&'. get_app