Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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

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: 27211
87
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: 27211
87
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: 12199
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: 27211
87
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
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic