Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > My XML Feed Choked

Reply
Thread Tools

My XML Feed Choked

 
 
Malcolm Dew-Jones
Guest
Posts: n/a
 
      11-03-2005
Joe Cox ((E-Mail Removed)) wrote:
: I am relatively new to XML. I built a website using XML to transfer query
: results to web browsers. Everything was working and I was doing final
: testing before deploying it, but ran into an XML problem.

: I got the following error:


: Whitespace is not allowed at this location. Error processing resource
: 'http://compass/cgi-bin/keyword_search.php'. Line 15...

: <name>CO & CO</name>
: ------------^


: 'CO & CO' is a string that represents the name of a company that was fed out
: of the database as part of a query result. My PHP code builds it into XML

(not quite)

: Apparently, XML doesn't like to see an '&' between it's tags. I though XML
: ignored everything between tags, so why does it snag on this?

No. Various things must be escaped, most obviously > by using &gt;

"&" itself must therefore also be escaped, by using &amp;

(To ensure no misunderstanding, the above escapes, with each character
quoted)

"&" "g" "t" ";"

"&" "a" "m" "p" ";"


Is there a
: simple fix to this or must I go back and write exception code to handle
: these?

When you generate the XML you must escape various things. I'm sure there
are XML libraries for PHP that make it easy to generate valid XML from
arbitrary input, but I don't know any names off hand.




--

This programmer available for rent.
 
Reply With Quote
 
 
 
 
Joe Cox
Guest
Posts: n/a
 
      11-03-2005
I am relatively new to XML. I built a website using XML to transfer query
results to web browsers. Everything was working and I was doing final
testing before deploying it, but ran into an XML problem.

I got the following error:


Whitespace is not allowed at this location. Error processing resource
'http://compass/cgi-bin/keyword_search.php'. Line 15...

<name>CO & CO</name>
------------^


'CO & CO' is a string that represents the name of a company that was fed out
of the database as part of a query result. My PHP code builds it into XML
Apparently, XML doesn't like to see an '&' between it's tags. I though XML
ignored everything between tags, so why does it snag on this? Is there a
simple fix to this or must I go back and write exception code to handle
these?

Any suggestion would be appreciated.


 
Reply With Quote
 
 
 
 
Johannes Koch
Guest
Posts: n/a
 
      11-03-2005
Joe Cox wrote:
> <name>CO & CO</name>
> ------------^


& -> &amp;

--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
 
Reply With Quote
 
Joe Cox
Guest
Posts: n/a
 
      11-04-2005
Thanks. I was able to repair it with a few regex-replace statements.

"Joe Cox" <(E-Mail Removed)> wrote in message
news:dkdvk3$17m$(E-Mail Removed)...
>I am relatively new to XML. I built a website using XML to transfer query
>results to web browsers. Everything was working and I was doing final
>testing before deploying it, but ran into an XML problem.
>
> I got the following error:
>
>
> Whitespace is not allowed at this location. Error processing resource
> 'http://compass/cgi-bin/keyword_search.php'. Line 15...
>
> <name>CO & CO</name>
> ------------^
>
>
> 'CO & CO' is a string that represents the name of a company that was fed
> out of the database as part of a query result. My PHP code builds it into
> XML
> Apparently, XML doesn't like to see an '&' between it's tags. I though XML
> ignored everything between tags, so why does it snag on this? Is there a
> simple fix to this or must I go back and write exception code to handle
> these?
>
> Any suggestion would be appreciated.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dsl UPSTREAM choked..... steve NZ Computing 6 01-15-2006 07:39 AM
Mail-choked server Maybe Computer Support 4 08-29-2005 06:41 PM
Choked up E-Mail, where's Heimlich when you need him? dah_dah Computer Support 5 06-24-2005 09:13 PM
IM died - here's the msg it choked on Richard Muller ASP General 1 10-16-2003 08:51 PM
Can't read entire record - fscanf (choked up) Blankdraw C Programming 2 08-27-2003 02:28 PM



Advertisments