This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

special character in xml

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
& lt ;
[ February 13, 2003: Message edited by: Thomas Paul ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
&lt;
which you in turn get by writing
&amp;lt;
which you in turn get by writing
&amp;amp;lt;
which you in turn get by writing
&amp;amp;amp;lt;
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 ]
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic