My XML Feed Choked

Discussion in 'XML' started by Malcolm Dew-Jones, Nov 3, 2005.

  1. Joe Cox () 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.
     
    Malcolm Dew-Jones, Nov 3, 2005
    #1
    1. Advertising

  2. Malcolm Dew-Jones

    Joe Cox Guest

    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.
     
    Joe Cox, Nov 3, 2005
    #2
    1. Advertising

  3. 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)
     
    Johannes Koch, Nov 3, 2005
    #3
  4. Malcolm Dew-Jones

    Joe Cox Guest

    Thanks. I was able to repair it with a few regex-replace statements.

    "Joe Cox" <> wrote in message
    news:dkdvk3$17m$...
    >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.
    >
     
    Joe Cox, Nov 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruce W..1

    How to make a blog with an XML feed?

    Bruce W..1, Dec 2, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    649
    Bruce W..1
    Dec 3, 2003
  2. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    Line Feed & Carriage Return with XML?

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Oct 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    12,101
    Kevin Spencer
    Oct 25, 2004
  3. Steve Peterson

    XML Feed

    Steve Peterson, Dec 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    425
    Steve Peterson
    Dec 26, 2004
  4. Blankdraw

    Can't read entire record - fscanf (choked up)

    Blankdraw, Aug 25, 2003, in forum: C Programming
    Replies:
    2
    Views:
    537
    Eric Sosman
    Aug 27, 2003
  5. Richard Muller

    IM died - here's the msg it choked on

    Richard Muller, Oct 16, 2003, in forum: ASP General
    Replies:
    1
    Views:
    135
    Aaron Bertrand - MVP
    Oct 16, 2003
Loading...

Share This Page