How to use Escape Sequence with XML
There are two ways to use escape sequence 1) Either two replace these from their counterparts 2) Either use CDATA section for these.
1) First Way Using CData Section
If your text contains a lot of "<" or "&" characters - the XML element can be defined as a CDATA section.
All text in an XML document will be parsed by the parser. Only text inside a CDATA section will be ignored by the parser.
2. Replace with their CounterParts
Illegal XML characters have to be replaced by entity references.
If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element. You cannot write something like this:
if salary < 1000 then
To avoid this, you have to replace the "<" character with an entity reference, like this:
if salary < 1000 then
There are 5 predefined entity references in XML: Replace these with their counter part specified in B A B & & < < > > " " ' '
Note: Only the characters "<" and "&" are strictly illegal in XML. Apostrophes, quotation marks and greater than signs are legal, but it is a good habit to replace them.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|