?
Solved

How to pass symbols in xml tag

Posted on 2001-09-14
2
Medium Priority
?
725 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
GedB earned 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

801 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