Re: XML CDATA special characters
From: John van Terheijden (john-foobar-nl)
Date: 11/18/03
- Next message: Shawn Wilson: "Re: Payment function"
- Previous message: Pedro Graca: "Re: how do I hide database connection files using PHP include files?"
- In reply to: Terence: "Re: XML CDATA special characters"
- Next in thread: Terence: "Re: XML CDATA special characters"
- Reply: Terence: "Re: XML CDATA special characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 18 Nov 2003 21:26:06 +0100
I didn't mention SAX, is that the standard PHP parser I'm using now? I
thought it was Expat. Thanks for making this even more confusing ;)
Ok, I'll just dive into DOM now and see where this will all end up. I'll
probably come across all the terms again, in time. B.t.w. I don't understand
much of your XSL note, probably because I know very little about XSL. I'm
using XML to store data while avoiding databases.
Thanks!
"Terence" <tk.lists@fastmail.fm> schreef in bericht
news:3fb9969e$1@herald...
> for a start, if you are "creating" XML content, then you need to use the
> DOM API and not the SAX API. As far as I am aware, the SAX API is just
> for "reading" XML data and not writing to it. Someone please correct me
> if I am wrong.
>
> The DOM API will conveniently do all special character escaping for you
> so you dont have to worry about using functions *like* htmlentities().
> On that point, basic XML only has 5 pre-defined default entities. And
> off the top of my head, I think they are:
>
> > -- >
> < -- <
> " -- "
> & -- &
> [insert fifth one here]
>
> The other one escapes me (no pun intended). If you try and use HTML
> entities, then you will likely create invalid XML documents because HTML
> has entities that are "undefined" in the default XML set.
>
> When you use an XML parser (be it SAX, or DOM) to get the data back from
> the XML storage files, everything (including entities) will be converted
> back (un-escaped). So you really do not need to use CDATA sections.
> CDATA sections do have their usages but their absolute neccecity is
> limited to a very few cases.
>
> SPECIAL NOTE ON XSL STYLESHEETS:
> If you are using XSL templates to extract HTML markup contained
> (escaped) in the XML storage files, use the disable-output-escaping
> attribute of the value-of directive to disable output escaping. This is
> useful if you have done something like this...
> $element->set_content($htmlSource);
> and you wish the output tree to contain unescaped HTML.
>
> As for character encoding (UTF8 etc), it depends on what sort of data
> you are putting in there. Odds are you needn't concern yourself with
> this unless you know that your source data is UTF-16 or something. Just
> try using the DOM XML functions and see how you go.
>
- Next message: Shawn Wilson: "Re: Payment function"
- Previous message: Pedro Graca: "Re: how do I hide database connection files using PHP include files?"
- In reply to: Terence: "Re: XML CDATA special characters"
- Next in thread: Terence: "Re: XML CDATA special characters"
- Reply: Terence: "Re: XML CDATA special characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]