• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jDom & EscapeStrategy for &

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating an XML document with jDom. The result XML file contains & instead of '&'. How can I escape these characters?
please throw some light on this..

thanks,
Mahesh
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you used standard XML software to output the DOM to an XML document, I would expect it to escape that character properly without being asked. That is just normal behaviour. Am I correct that your question is that your output contains something like

<text>This & that</text>

which is malformed XML, and you want it to contain this well-formed example instead?

<text>This &amp; that</text>

If so, let's see the code you are using to output the document.
 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually what I want is the opposite..

I am constructing a document from the data from excel file and the XML file contains "A &amp; B" instead of "A & B".
How can i achieve this?

Thanks
Mahesh

[Edit: modified example to match what appeared to be desired in the source of this posting.]
[ August 11, 2008: Message edited by: Andrew Monkhouse ]
 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this is the javaranch issue with displaying...
actually the xml file has "A & amp; B" instead of "A & B"
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, it isn't really a "Java Ranch issue". It's just HTML, which has the same escaping rules as XML. If you know the rules then you should be able to make it display what you want it to display.

Anyway, you seem to be saying that you don't want the correct XML, you actually want malformed XML. Is that right? If so, why?
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mahesh,

Please check your private messages for an important administrative matter.

Thanks, Andrew
 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I need the data as it is because I want to use this XML for processing data in other application. This is the requirement. The external application is not currently recognizing this escaped data..please note that i am not using this data to represent in the HTML. This is just for transaction purposes.

thanks,
Mahesh
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could write an XSL transformation to convert your document to malformed XML by using the "disable-output-escaping" attribute of the "xsl:text" element.
 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic