Parse elements in XML feed

Discussion in 'ASP General' started by glbdev@gmail.com, Apr 21, 2007.

  1. Guest

    I need to pull items out of an XML feed.

    Here is an example of the XML file:
    - <TopNode>
    - <XmlFeed>
    - <GetListInCategory>
    - <Data Count="937">
    - <Table>
    <EventID>567343</EventID>
    <Event>NHL playoffs</Event>
    <Date>2007-04-21T00:00:00.0000000-05:00</Date>
    <Time>10:00 PM</Time>
    <CategoryID>26</CategoryID>
    <HeadlinerID>101828</HeadlinerID>
    <VenueID>115920</VenueID>
    </Table>
    </data>
    </GetListInCategory>
    </TopNode>

    I need to pull each item out of the <TABLE> node, such as
    <CategoryID>. The current code I am using now pulls ALL the data but
    I cannot access the invidual elements.

    Here is my current code:

    dim objHTTP
    dim objXML
    set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
    objHTTP.open "GET","https://secure.myxmlfeed", false
    objHTTP.send
    set objXML = server.CreateObject("microsoft.xmldom")
    objXML.async=false
    objXML.load(objhttp.responsebody)
    Response.Write(objxml.xml)

    Can anyone tell me how to do this?

    - Steve
    , Apr 21, 2007
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > I need to pull items out of an XML feed.
    >
    > Here is an example of the XML file:
    > - <TopNode>
    > - <XmlFeed>
    > - <GetListInCategory>
    > - <Data Count="937">
    > - <Table>
    > <EventID>567343</EventID>
    > <Event>NHL playoffs</Event>
    > <Date>2007-04-21T00:00:00.0000000-05:00</Date>
    > <Time>10:00 PM</Time>
    > <CategoryID>26</CategoryID>
    > <HeadlinerID>101828</HeadlinerID>
    > <VenueID>115920</VenueID>
    > </Table>
    > </data>
    > </GetListInCategory>
    > </TopNode>
    >
    > I need to pull each item out of the <TABLE> node, such as
    > <CategoryID>. The current code I am using now pulls ALL the data but
    > I cannot access the invidual elements.
    >
    > Here is my current code:
    >
    > dim objHTTP
    > dim objXML
    > set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")


    Don't use the XMLHTTP in ASP it's not threadsafe. Use:-

    Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")

    > objHTTP.open "GET","https://secure.myxmlfeed", false
    > objHTTP.send


    > set objXML = server.CreateObject("microsoft.xmldom")
    > objXML.async=false
    > objXML.load(objhttp.responsebody)


    If the remote source is behaving itself and sending a content-type header
    with the value "text/xml" then you need only:-

    Set objXML = objHTTP.ResponseXML

    > Response.Write(objxml.xml)
    >
    > Can anyone tell me how to do this?


    Dim oTable
    Dim oNode

    Set oTable =
    objXML.selectSingleNode("/TopNode/XMLFeed/GetListInCategory/Data/Table")

    For Each oNode In oTable.selectNodes("*")
    Response.Write oNode.tagName & " = " & oNode.Text & "<br />"
    Next


    >
    > - Steve
    >
    Anthony Jones, Apr 22, 2007
    #2
    1. Advertising

  3. Guest

    Thanks Anthony, I appreciate it. I will give this a try later this
    afternoon.

    - Gust
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    On Apr 22, 3:22 am, "Anthony Jones" <> wrote:

    > <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > I need to pull items out of an XML feed.

    >
    > > Here is an example of the XML file:
    > > - <TopNode>
    > > - <XmlFeed>
    > > - <GetListInCategory>
    > > - <Data Count="937">
    > > - <Table>
    > > <EventID>567343</EventID>
    > > <Event>NHL playoffs</Event>
    > > <Date>2007-04-21T00:00:00.0000000-05:00</Date>
    > > <Time>10:00 PM</Time>
    > > <CategoryID>26</CategoryID>
    > > <HeadlinerID>101828</HeadlinerID>
    > > <VenueID>115920</VenueID>
    > > </Table>
    > > </data>
    > > </GetListInCategory>
    > > </TopNode>

    >
    > > I need to pull each item out of the <TABLE> node, such as
    > > <CategoryID>. The current code I am using now pulls ALL the data but
    > > I cannot access the invidual elements.

    >
    > > Here is my current code:

    >
    > > dim objHTTP
    > > dim objXML
    > > set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")

    >
    > Don't use the XMLHTTP in ASP it's not threadsafe. Use:-
    >
    > Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
    >
    > > objHTTP.open "GET","https://secure.myxmlfeed", false
    > > objHTTP.send
    > > set objXML = server.CreateObject("microsoft.xmldom")
    > > objXML.async=false
    > > objXML.load(objhttp.responsebody)

    >
    > If the remote source is behaving itself and sending a content-type header
    > with the value "text/xml" then you need only:-
    >
    > Set objXML = objHTTP.ResponseXML
    >
    > > Response.Write(objxml.xml)

    >
    > > Can anyone tell me how to do this?

    >
    > Dim oTable
    > Dim oNode
    >
    > Set oTable =
    > objXML.selectSingleNode("/TopNode/XMLFeed/GetListInCategory/Data/Table")
    >
    > For Each oNode In oTable.selectNodes("*")
    > Response.Write oNode.tagName & " = " & oNode.Text & "<br />"
    > Next
    >
    >
    >
    >
    >
    > > - Steve- Hide quoted text -

    >
    > - Show quoted text -- Hide quoted text -
    >
    > - Show quoted text -
    , Apr 22, 2007
    #3
  4. Guest

    Pupkin,

    I never heard of RSS2HTML but will look into it.

    Thanks,
    - Steve
    ==========================================================================================================

    On Apr 22, 3:25 am, Pupkin <> wrote:
    > Google the RSS2HTML code. It can be easily customized to take any XML
    > doc and use it as a sort of lightweight database for web apps.
    >
    >
    >
    > > I need to pull items out of an XML feed.

    >
    > > Here is an example of the XML file:
    > > - <TopNode>
    > > - <XmlFeed>
    > > - <GetListInCategory>
    > > - <Data Count="937">
    > > - <Table>
    > > <EventID>567343</EventID>
    > > <Event>NHL playoffs</Event>
    > > <Date>2007-04-21T00:00:00.0000000-05:00</Date>
    > > <Time>10:00 PM</Time>
    > > <CategoryID>26</CategoryID>
    > > <HeadlinerID>101828</HeadlinerID>
    > > <VenueID>115920</VenueID>
    > > </Table>
    > > </data>
    > > </GetListInCategory>
    > > </TopNode>

    >
    > > I need to pull each item out of the <TABLE> node, such as
    > > <CategoryID>. The current code I am using now pulls ALL the data but
    > > I cannot access the invidual elements.

    >
    > > Here is my current code:

    >
    > > dim objHTTP
    > > dim objXML
    > > set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
    > > objHTTP.open "GET","https://secure.myxmlfeed", false
    > > objHTTP.send
    > > set objXML = server.CreateObject("microsoft.xmldom")
    > > objXML.async=false
    > > objXML.load(objhttp.responsebody)
    > > Response.Write(objxml.xml)

    >
    > > Can anyone tell me how to do this?

    >
    > > - Steve- Hide quoted text -

    >
    > - Show quoted text -
    , Apr 22, 2007
    #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. P
    Replies:
    1
    Views:
    1,161
    Joe Kesselman
    Jul 7, 2006
  2. Replies:
    2
    Views:
    300
  3. Replies:
    19
    Views:
    1,121
    Daniel Vallstrom
    Mar 15, 2005
  4. Ultrus
    Replies:
    4
    Views:
    2,589
    Stefan Behnel
    Aug 30, 2007
  5. Chris Seberino
    Replies:
    3
    Views:
    744
    Stefan Behnel
    Jun 12, 2009
Loading...

Share This Page