wood burning stoves
The moose likes Java in General and the fly likes special character in xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "special character in xml" Watch "special character in xml" New topic

special character in xml

rose deng
Ranch Hand

Joined: Dec 29, 2000
Posts: 78
As far as i know, & and < are special characters for xml. so we need to escape those two characters to make the string be well-formed xml string.
& is easy to handle, just encode it to & ;.afer validation or transformation, decode it back.
My question is how to encode < sign in element value, seems can not just encode it to < ;, since it's hard to differieciated less than sign from open tag
If you have solution, share with me please.
Huge thanks.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
& lt ;
[ February 13, 2003: Message edited by: Thomas Paul ]

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
It looks like Rose was trying to write "&lt;" in the first place, but wrote "&lt ;" (trying to fool UBB) and UBB (or the browser?) converted this to "< ;". Very .
Anyway, to write
in UBB type
which you in turn get by writing
which you in turn get by writing
which you in turn get by writing
etc. :roll: Usually you just need to go just one or two steps into this progression, but in order to talk about step 1 you need to use step 2, etc.
To anwer what I think was the intended question - when you write a "<", you usually need to know at the time whether it's the beginning of a tag (in which case write it as "<") or part of the text content of a tag (in which case replace it with "&lt;"). I guess it really depends where you're getting this data from, but in most contexts I can imagine you should already know if it's content or markup. The only exception I can think of is if you're reading an XML file which was not properly encoded to beging with, and you're trying to fix it. But perhaps you (Rose) should tell us more about where the data comes from, before we get into all the possibilities here.
[ February 13, 2003: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
I agree. Here's the link: http://aspose.com/file-tools
subject: special character in xml
It's not a secret anymore!