Solved

How to pass symbols in xml tag

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
ASP.NET reading ATOM 2 74
Import data into excel from web page 10 111
migrating to phpbb forum from vBulletin 4.2 3 40
xml files 7 54
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

726 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