Solved

How to pass symbols in xml tag

Posted on 2001-09-14
2
707 Views
Last Modified: 2013-11-19
How to pass symbols in xml tag like:

<flag> <= STATIC</flag> it gives error at <=

It is giving me parser error.
How to pass other symbols like %, & does it give parsing error.


0
Comment
Question by:vmandem
2 Comments
 
LVL 1

Accepted Solution

by:
GedB earned 50 total points
ID: 6483765
The problem is that some symbols confuse the parser.  With the less than sign (<) the parser thinks you have opened a new element.  When it fails to find a corresponding greater than sign to close the element it gives an error.

XML has two features to get around this problem.

1)   Character Encoding

2)   CDATA sections


Character Encoding involves replacing the symbol with an entity.  The main entitys are:

         &gt;          Greater than
         &lt;          Less than
         &amp;         Ampersand

Any other symbol can be represented with &#ddd; where ddd is the decimal character code or &#xhh; when nn is hexadecimal equivalent.  This would make the percentage sign &#37; or &#x25;

Declaring a CDATA section escapes the parser from the XML, and it treats everything inside the section as a character.

A CDATA section begins with <![CDATA[ and ends with ]]>

In this example you would use <flag><[!CDATA[ <= STATIC]]></flag>

If you are coding the XML yourself, then encoding is probably the best way to do it.

If you are bolting together you xml from other sources, then its probably easiest to use a CDATA section.
0
 

Author Comment

by:vmandem
ID: 6484259
I found this answer in a book but anyway i will accept your answer and thankyou for your response.

VMandem
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now