Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: CDATA in an XML file for parsing.

by BaldPenguin (Friar)
on Jan 02, 2006 at 21:46 UTC ( [id://520460]=note: print w/replies, xml ) Need Help??


in reply to CDATA in an XML file for parsing.

Stick with XML::LibXML , while it may be easy to say Don't do that witht CDATA and embedded markup, I believe it's impractical. I have many stylesheets and XML pages that dynamically generate HTML including javascript sections based upon the XML nodes. Even if you have control over how the XML files are created, it may not be prudent to remove all embedded tags. It is in that regard that the ability to include embedded tags in CDATA Sections was created/allowed (in my opinion anyway).

Don
WHITEPAGES.COM | INC
Everything I've learned in life can be summed up in a small perl script!

Replies are listed 'Best First'.
Re^2: CDATA in an XML file for parsing.
by Aristotle (Chancellor) on Jan 03, 2006 at 12:10 UTC

    The point is that <![CDATA[<foo>]]> and &lt;foo&gt; mean exactly the same thing. If you need to treat them differently, some piece of software in your chain is broken. (Yes, that means serving XHTML as HTML is broken.)

    CDATA is a shortcut for when text contains a lot of literal angle brackets and carries no further meaning.

    Makeshifts last the longest.

      I do not disagree that they are the same, and I have no intent on treating them differently. However, your comment on some peice of software in the chain being broken caught my attention. On of the main uses I have for XML is actually XSLT transforms. In that code I have in the paste used blocks of data from a database that contain XML markup, in sort of an basic content management schema. What would your suggestion be for obtaining that content and inserting it into the XML document before it goes to the transfomer.

      Don
      WHITEPAGES.COM | INC
      Everything I've learned in life can be summed up in a small perl script!

        There are many many good articles and discussion threads out there that discuss this same (or similar) scenario.

        for example: this thread and this excellent article by tmoertel

        =oQDlNWYsBHI5JXZ2VGIulGIlJXYgQkUPxEIlhGdgY2bgMXZ5VGIlhGV

        You’re not giving me enough information to understand what the problem is and which constraints you need to honour, I’m afraid. Can you explain in more detail?

        Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://520460]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found