AboutSrini Nagarajan Expertise I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase
Experience Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.
Expert: Srini Nagarajan Date: 6/3/2008 Subject: XML Parsing Continued
Question QUESTION: Hi Srini, I ran out of follow-ups so they made me ask a new question. :) The last example you gave me works well when using an existing .xml file that lives on the local server. However, I get my XMl output from a remote PHP file on a server I have no control over. Because of that, I need to feed the contents of an XML file into the XMLDOM parser instead of a filename. That's where the hang-up is. See what I mean? All the stuff you showed me works beautifully if I have an actual local filename to feed into the parser, but I don't have that available unfortuantely. :( So again, this is the on thing I've tried so far with no success even though it "should" work in theory:
---
Set mydoc = Server.CreateObject("Microsoft.XMLDOM")
mydoc.loadXML(STRING_VARIABLE_CONTAINING_XML_CODE)
TotalA = mydoc.selectNodes("//dce/response/watchlists/watchlist").length
TotalB = mydoc.selectNodes("/dce/response/watchlists/watchlist").length
TotalC = mydoc.selectNodes("dce/response/watchlists/watchlist").length
---
All 3 total variables end up being 0. :( Hopefully you can help me with this. Thanks again for your assistance Srini. It's appreciated.
ANSWER: Hi,
Sorry for i was away and just checking your email.
when you get the XML from different Server thru URL into STRING_VARIABLE_CONTAINING_XML_CODE, are you getting any data?
Did you display the XML also did you see what is the ERR you are getting?
If your XML comes like this including XML and RESPONSE header
you should remove the first two lines, so that your /dce get the value directly.
I'll try to create a simple page for you and send the code once I am done.
Thanks
-Srini
---------- FOLLOW-UP ----------
QUESTION: Thanks Srini. I'm not getting any errors and yes I did display the STRING_VARIABLE_CONTAINING_XML_CODE which is well formed. However, it does indeed contain the header variables. Here's an excerpt of the XML I'm feeding as the STRING_VARIABLE_CONTAINING_XML_CODE variable:
So you think I should somehow strip out the XML and doctype header? Hmmmm. Not sure how I would do that, but anything's worth a try at this point. :) Looking forward to seeing your code. I don't think I've ever been this stuck before. :)
ANSWER: Hi,
I am busy with moving my house (so tired not able to type~!!!) once I setup everything I'll spend some time to create a page for you.
THanks
-Srini
---------- FOLLOW-UP ----------
QUESTION: No problem at all. I know how hectic that can be. Just don't forget about me! :)
Answer Hi
I dedicated few hours for you and found the solution!! :)
here is the issue
<name>mp3 players & calculators</name> - You can't have & (and sign) in the XML.
This will suppose to work as part of DocType entity... But ASP is not supporting Entity and throwing error!!!
Can you check the following code this should work for you. And also display detailed Error Message,
Please change the variable to your variable name and give a try.