|
|
Subject:
XML and & Symbol in ASP
Category: Computers > Programming Asked by: xemion-ga List Price: $18.00 |
Posted:
16 Jan 2003 12:02 PST
Expires: 15 Feb 2003 12:02 PST Question ID: 144328 |
I'm having problems with an XML feed. I use the below ASP code to download the feed: Set objSrvHTTP = Server.CreateObject ("MSXML2.ServerXMLHTTP") objSrvHTTP.open "GET","http://www.website.com?getfeed=1", false objSrvHTTP.send if objSrvHTTP.responseXML.getElementsByTagName("ErrCount").item(0).text <> 0 then the feed looks like this: <?xml version="1.0"?> <interface-response> <host> <name>@</name> <type>FRAME</type> <address>http://www.website.com?x=1&y=2</address> </host> <ErrCount>0</ErrCount> <debug><![CDATA[]]></debug> </interface-response> The problem is with the <address> data. When that data is a full url with parameters (with a "&y=2") I get an error. The error looks like this: Microsoft VBScript runtime (0x800A01A8) Object required: '[object]' The line at which the error occurs is the "if error = 0 then" line. If the <address> field does not have a "&" and looks just like "http://www.website.com?x=1" then I have no problems. My question is...why is that "&" causing an error when I try to parse my XML? Also, if you can answer how to keep it from happening, that would be greatly appreciated (think "tip" ;-). Please ask any questions if you have them, thank you. As always, rating will be give. xemion-ga | |
|
|
Subject:
Re: XML and & Symbol in ASP
Answered By: davebug-ga on 16 Jan 2003 14:05 PST Rated: |
As the ampersand is used to signify the encoding of an entity (ie escaped character) it needs to be, itself, encoded as an entity. Thus, the url address will need to be entered as: http://www.website.com?x=1&y=2 wherein the ampersand in the URL is replaced with & In order to ensure that this encoding comes across your way accurately and is not interpreted by the browsers, I'm going to post this with spaces between each character: & a m p ; There are a total of five predefined entities available in XML, further explained and listed here: http://msxml.com/intro_xml/entities.html --- In some articles on the subject it is recommended, for interoperability with SGML and other mark-up languages, that the entity name be replaced with &#38; XML Entities and their Applications (in the subsection of "Predefined Entities") http://tech.irt.org/articles/js212/#character_references Let me know if this fully answers your question and feel free to ask for any further clarifications. Thanks for using Google Answers, Dave Bug | |
| |
|
xemion-ga
rated this answer:
Thanks for the help! |
|
Subject:
Re: XML and & Symbol in ASP
From: richardli-ga on 16 Jan 2003 13:37 PST |
Attributes and any other parsed character text that use the reserved characters &, > or < have to encode them as character entities. Replace the ampersand with & |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |