Solved

How to pass symbols in xml tag

Posted on 2001-09-14
2
708 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
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 …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to count occurrences of each item in an array.

948 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

22 Experts available now in Live!

Get 1:1 Help Now