If you could give an example of this "simple text" it would help, but
my guess is that you haven't realised just how strict the XML parser
is. The validator forbids the use of any of the following characters
in a text node unless they are encoded:
& (ampersand, must be encoded as &)
< (left angle bracket, must be encoded as <)
> (right angle bracket, must be encoded as >)
and a whole bunch of others, such as non-ascii character entities. To
ensure that the user input is valid, you will either need to encode
all forbidden characters as above, or use a CDATA block, as suggested
by Jason. Which of these is the better option probably depends on the
application. For ordinary English text I'd go for encoding the
characters; for foreign text or binary data it will be much easier
and more efficient to use CDATA.
Nick
On 5 Apr 2006, at 18:27, Marc Zeedar wrote:
Hi gang!
I'm getting into XML and I've run into a puzzle. My app saves and
loads
XML files, but suddenly I'm getting a few beta testers with files that
won't open. These files were created by my app. I get an XMLException
right at the "loadXML" parse command with an error of "XML parser
error 3:
not well-formed (invalid token)."
What I can't figure out is where the error is lcoated. The line number
shows an innocuous line in the XML and when I delete that "bad" XML
node
it just gives me an error at a different line. If I delete enough
stuff
eventually the file will open, but there doesn't seem to be a rhyme or
reason to it.
Since the XML in question is generated by my app, the actual
formation of
the tags is standard; since some files work and some don't, it
can't be in
how I'm nesting the tags. The only thing I can think of is that
there's
something in the user's *content* (data being saved) that's causing
the
error, but the data appears to be pretty simple text.
Any ideas how to debug this? I'm a bit at a loss since it just
errors when
I pass the XML to the parser, with no way of figuring out what,
exactly,
is causing the problem.
Oh, and I'm using RB5.5.5 -- I haven't yet converted my app to
RB2005/6
yet. Don't know if that makes a difference, but if it's a bug in
RB's XML
parser I suppose it might be fixed in a more recent release.
--
Marc Zeedar
Publisher
REALbasic Developer Magazine
http://www.rbdeveloper.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>