Solved

How to pass symbols in xml tag

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Detect file exist or not 3 177
How to get statistic's from a competitors website?! 1 112
XSLT list item selection criteria not working 12 34
removing a class in javascript 4 46
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

789 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