Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

escaping HTML snippets in XML file

  • 24-05-2007 06:33PM
    #1
    Registered Users, Registered Users 2 Posts: 2,011 ✭✭✭


    I'm getting the output of another application (currently in XML) and parsing it to display on screen.

    I can parse the XML pretty easily, but I can't seem to remember how to parse the HTML bits within the xml fields, it seems to fragment the html more than it should.

    So there's the output:
    <product>
       <title>Product title</title>
       <description>This is the description which uses <b>bold</b> and some <br> tags too</description>
    </product>
    

    Any ideas?


Comments

  • Closed Accounts Posts: 831 ✭✭✭Laslo


    <product>
       <title>Product title</title>
       <description><![CDATA[This is the description which uses <b>bold</b> and some <br> tags too]]></description>
    </product>
    


  • Registered Users, Registered Users 2 Posts: 2,011 ✭✭✭colm_c


    That was my first thought but, unfortunately that's not really an option - the application that's outputting this is built in Java and can't be changed, is there a way to insert these on the fly?


  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    It's been years since I did much with XML, but I don't suppose you could use an XSLT(?) document to define what fields in the XML doc can have cdata?


  • Registered Users, Registered Users 2 Posts: 2,011 ✭✭✭colm_c


    Got it working in the end, the XML coming back had escaped the characters, but was fragmenting on the amperands, ended up checking the path and concatenating the fragments together.

    Thanks for the help.


Advertisement