Re: Why XML not well formed?
by davorg (Chancellor) on Jun 30, 2005 at 13:07 UTC
|
Have you taken a close look at line 221, column 97? That's where your problem is.
--
< http://www.dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] [Watch: Dir/Any] |
|
perl -le 'open(X,shift())or die "$!";seek(X, 12000, 0)or die "$!";read
+ X, $b, 40;print $b, "\n", " " x 19, "^\n"' foo.xml
Update: Oop, I see by the paths mentioned you're on Wintendo; you'll probably want to adjust the quotes on that or store it into a file and run that (or just get a real shell and/or OS . . . :)
--
We're looking for people in ATL
| [reply] [Watch: Dir/Any] [d/l] |
|
Hi guys,
Thank you for your quicky replies. I think I found what's wrong inside xml document. It seems that only if a link contains character '&' then the parser reports an error.
For example, <link r:resource="http://www.urbancinefile.com.au/home/article_view.asp?Article_ID=3801&Section=Reviews"/>
As I need to read <link/> elements one by one and compare the attribute value with user's input, my new question is, how can I overcome this '&' problem? I have tried to use '\' before '&' but it doesn't work.
Thanks again,
Nan
| [reply] [Watch: Dir/Any] |
|
If you are being passed data that contains a raw '&' character that hasn't been converted to '&' then you aren't being passed valid XML and no XML parser will be able to deal with it.
You should ask your data provider to fix their processes so that they _do_ sent you valid XML.
--
< http://www.dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] [Watch: Dir/Any] |
|
Re: Why XML not well formed?
by mirod (Canon) on Jun 30, 2005 at 13:34 UTC
|
As mentionned before, there is probably nothing wrong with the script, just something wrong with the data. Try looking at line 221, column 97, or using the ErrorContext => 1 argument when you create the XML::Parser object, which will display the faulty line.
A not well-formed (invalid token) error is often found when an ampersand (&) or an opening bracket (<) are not escaped in the XML.
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
You fixed my issue as well. I had "&" characters in my data. Thank you very much.
| [reply] [Watch: Dir/Any] |
Re: Why XML not well formed?
by BaldPenguin (Friar) on Jun 30, 2005 at 15:40 UTC
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
$line =~ s/(&)/$1amp;/g;
Edit by castaway: Closed small tag in signature | [reply] [Watch: Dir/Any] [d/l] |
|
|
|
|
|
|