RE: [xml] Problems with the character & and saving/loading XML files
- From: "Daniel Gehriger" <bulk linkcad com>
- To: "'Philip Van Hoof'" <freax pandora be>
- Cc: <xml gnome org>
- Subject: RE: [xml] Problems with the character & and saving/loading XML files
- Date: Fri, 19 Apr 2002 15:20:05 +0200
Philip,
The following two characters must be escaped: '<' and '&'.
You could also use a CDATA section, like this:
<mydata><![CDATA[ ANY DATA ]]></mydata>
, but then you mustn't use "]]>" inside the CDATA section, and there's
no way to escape this sequence. You better don't use CDATA for this
reason.
Here's a link with more information:
http://www.w3schools.com/xml/xml_cdata.asp
- Daniel
-----Original Message-----
From: xml-admin gnome org [mailto:xml-admin gnome org] On
Behalf Of Daniel Veillard
Sent: Friday, 19 April, 2002 13:57
To: Philip Van Hoof
Cc: xml gnome org
Subject: Re: [xml] Problems with the character & and
saving/loading XML files
On Fri, Apr 19, 2002 at 01:31:07PM +0200, Philip Van Hoof wrote:
Hi there..
I want to store a struct as an XML file and after that
reload the XML
file into such a struct. The data of the struct can contain any
character. Including characters like &, <, > , +, " and '. If I save
Some of them MUST be escaped when present in XML
my struct and there is for example a character "&" in the
data; then
loading the XML file fails.
Rule #1 to get help:
- provide meaningful reports, what is the error ????
Rule #2:
- follow the instructions
http://xmlsoft.org/bugs.html
"Do not send code, I won't debug it" is in bold, maybe I need
to make it red too.
How can I make it this way that I can save "any" data. So the
You cannot. You MUST escape characters which are not
acceptable XML is a text format, live with it.
<data></data> tag can contain any character.. do I need to
search/replace XML characters? Or is there a function in
the lib for
this?
when present in content & and < are automatically escaped
by libxml when saving, so I don't understand, and without the
error messages the only possibility is to make guesses and I
don't have the time for guess play.
ps. Don't be hard on me :) I am pretty new to libxml. Read
: This is
the first time that I use the library.
Well this doesn't mean that you should not do the minimal
reasearch on your side or follow the instructions. The fact
that XML requires escaping of & and < in content is the #1
point of any beginner XML FAQ. And you report is far too
incomplete to be able to answer (and no sorry I don't have
the time to debug your code).
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/ _______________________________________________
xml mailing list, project page http://xmlsoft.org/ xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]