Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parse xml dom 2

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
Hi i'm not sure what i'm doing wrong but i'm sure its simple
, thanks

Code:
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.load (Server.MapPath("sftp.asp")) 

IF (objXML.parseError.errorCode <> 0) THEN 

ELSE 

    Set objNode = objXML.SelectSingleNode("/IATA/@iNumber")

   If not objNode Is Nothing Then
      strUsername = objNode.text
        Set objNode = Nothing
    End If

END IF

and the xml is:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Reservation_Delivery>
    <Header>
        <Language>ENGLISH</Language>
        <IATA>
            [b]<iNumber>99986493</iNumber>[/b]
            <AgencyName>AUTO-CREATED</AgencyName>
            <AgencyAddress1>ADDRESS LINE 1</AgencyAddress1>
            <AgencyAddress2>ADDRESS LINE 2</AgencyAddress2>
            <AgencyCity>TULSA</AgencyCity>
            <AgencyState>OKLAHOMA</AgencyState>
            <AgencyCountry>United States</AgencyCountry>
            <AgencyPhoneNumer>9999999999</AgencyPhoneNumer>
        </IATA>
        <CRSID>RK</CRSID>
    </Header>
    <BookRPInfo>
        <PropID>100015</PropID>
        ...................... etc
 
Well, you didn't provide an error message or description of your problem, but the following line look s a bit off to me:
Code:
objXML.load (Server.MapPath("sftp.asp"))

I don't think that's doing what you thing it's doing.

 
Thanks Tarwn, but i tried that, i get error:
Invalid at the top level of the document.

Does it matter that i'm creating the XMLDOM object and trying to parse the elements in the same page that the xml schema resides?



 
>Set objNode = objXML.SelectSingleNode("/IATA/@iNumber")
[tt]Set objNode = objXML.SelectSingleNode("//IATA/iNumber") 'understood, the first[/tt]
 
So sftp.asp is a properly formed XML document?

Load can load an XML file one of two ways: either load a local file or load a URL. If you load an ASP file as a local file it doesn't get processed by IIS.
Server.MapPath returns a local path to a given virtual path.
Therefore unless the contents of that ASP file are a properly formed XML file, it is not going to load into the parser correctly and you will get an error at the top level of the document.

on the other hand, if you were to load that ASP page as a remote resource:
Code:
objXML.load ("[URL unfurl="true"]http://www.mydomain.com/sftp.asp")[/URL]
you might have better luck.

-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top