Re: [gdome]do I need to escape invalid xml characters?
- From: Paolo Casarini <casarini CS UniBO IT>
- To: rob <mailingLists pangolin org uk>
- Cc: gdome <gdome gnome org>
- Subject: Re: [gdome]do I need to escape invalid xml characters?
- Date: Mon, 11 Jun 2001 00:43:56 +0200 (CEST)
Sorry for the late...
> When i'm adding text to text node do I need to escape & < etc. or is it
> done for me?
When you set a string as the new content of a GdomeText node, characters
like default entity references, they are automatically replaced with their
"escaped" version: "&" -> "&", "<" -> "<", and so on.
> Is this ture for all the other types of node ?
No: no for comments, no for cdata sections, no for pi ad so on.
In general if you want to write the character '&' out of a GdomeText node
you have simply to write '&' and also the XML output should be the
same. Only in Text node we have to have "&" but you haven't to worry
about this because Gdome2 does it for you (or better libxml2 does it for
Gdome2).
Example. If I want to have the following output in a XML file:
...
<!-- I like the character & -->
<P&A>Hi rob &&&&!!</P&A>
...
I have to write something like this:
...
str = gdome_str_mkref (" I like the character & ");
cmt = gdome_doc_createComment (doc, str, &exc);
gdome_str_unref (str);
str = gdome_str_mkref ("P&A");
el = gdome_doc_createElement (doc, str, &exc);
gdome_str_unref (str);
str = gdome_str_mkref ("Hi rob &&&&!!");
txt = gdome_doc_createTextNode (doc, str, &exc);
gdome_str_unref (str);
tmp_node = gdome_el_appendChild (el, txt, &exc);
gdome_n_unref (tnode, &exc);
...
Bye
Paolo
--
Paolo Casarini - casarini cs unibo it
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]