aspose file tools*
The moose likes XML and Related Technologies and the fly likes Escape character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Escape character" Watch "Escape character" New topic
Author

Escape character

Joon Park
Greenhorn

Joined: Jul 10, 2001
Posts: 6
Hello,
I need to read "<" from a xml file, but I get
org.xml.sax.SAXParseException:The content beginning "<" is not legal markup... Is there some kind of escape character in xml?
...
<CONTENT>if(a < b)
b = a;
a = 0;
</CONTENT>
Above code snippet is what I want to read from a xml file. Thanks in advance for your help.
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
"<" symbol is illegal in XML, you have to escape it as "&lt;"
[This message has been edited by Mapraputa Is (edited August 06, 2001).]


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
Special characters are handled through entities.
An entity reference like < contains a name (in this case, �lt�) between the start and end delimiters. The text it refers to (< ) is substituted for the name, like a macro in a C or C++ program. The following table shows the predefined entities for special characters

Character Reference
& &
< <
> >
" "
' '


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Joon Park
Greenhorn

Joined: Jul 10, 2001
Posts: 6
Thanks guys,
"& l t;" seems to be working in place of "<".
[This message has been edited by Joon Park (edited August 06, 2001).]
[This message has been edited by Joon Park (edited August 06, 2001).]
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Errr... "<" is &lt; , not &amp; - I corrected my post
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Escape character