XML and & Symbol in ASP
-
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
-
Answer:
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 at Google Answers Visit the source
Related Q & A:
- How can I allow user to create posts in website using ASP.NET?Best solution by Programmers
- How to Undo previous action in asp.net?Best solution by forums.asp.net
- How to Search using jQuery ASP.Net?Best solution by Stack Overflow
- How to convert build.xml to maven pom.xml file?Best solution by Stack Overflow
- Why are there some planes that have a Flag or national symbol on the rudder along with the Fuselage symbol?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.