Parse elements in XML feed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • glbdev@gmail.com

    Parse elements in XML feed

    I need to pull items out of an XML feed.

    Here is an example of the XML file:
    - <TopNode>
    - <XmlFeed>
    - <GetListInCateg ory>
    - <Data Count="937">
    - <Table>
    <EventID>567343 </EventID>
    <Event>NHL playoffs</Event>
    <Date>2007-04-21T00:00:00.000 0000-05:00</Date>
    <Time>10:00 PM</Time>
    <CategoryID>2 6</CategoryID>
    <HeadlinerID>10 1828</HeadlinerID>
    <VenueID>115920 </VenueID>
    </Table>
    </data>
    </GetListInCatego ry>
    </TopNode>

    I need to pull each item out of the <TABLEnode, 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.CreateOb ject("Microsoft .XMLHTTP")
    objHTTP.open "GET","http s://secure.myxmlfee d", false
    objHTTP.send
    set objXML = server.CreateOb ject("microsoft .xmldom")
    objXML.async=fa lse
    objXML.load(obj http.responsebo dy)
    Response.Write( objxml.xml)

    Can anyone tell me how to do this?

    - Steve

  • Anthony Jones

    #2
    Re: Parse elements in XML feed


    <glbdev@gmail.c omwrote in message
    news:1177192579 .567005.51270@l 77g2000hsb.goog legroups.com...
    I need to pull items out of an XML feed.
    >
    Here is an example of the XML file:
    - <TopNode>
    - <XmlFeed>
    - <GetListInCateg ory>
    - <Data Count="937">
    - <Table>
    <EventID>567343 </EventID>
    <Event>NHL playoffs</Event>
    <Date>2007-04-21T00:00:00.000 0000-05:00</Date>
    <Time>10:00 PM</Time>
    <CategoryID>2 6</CategoryID>
    <HeadlinerID>10 1828</HeadlinerID>
    <VenueID>115920 </VenueID>
    </Table>
    </data>
    </GetListInCatego ry>
    </TopNode>
    >
    I need to pull each item out of the <TABLEnode, 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.CreateOb ject("Microsoft .XMLHTTP")
    Don't use the XMLHTTP in ASP it's not threadsafe. Use:-

    Set objHTTP = Server.CreateOb ject("MSXML2.Se rverXMLHTTP.3.0 ")
    objHTTP.open "GET","http s://secure.myxmlfee d", false
    objHTTP.send
    set objXML = server.CreateOb ject("microsoft .xmldom")
    objXML.async=fa lse
    objXML.load(obj http.responsebo dy)
    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.Respons eXML
    Response.Write( objxml.xml)
    >
    Can anyone tell me how to do this?
    Dim oTable
    Dim oNode

    Set oTable =
    objXML.selectSi ngleNode("/TopNode/XMLFeed/GetListInCatego ry/Data/Table")

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

    >
    - Steve
    >

    Comment

    • Pupkin

      #3
      Re: Parse elements in XML feed



      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>
      - <GetListInCateg ory>
      - <Data Count="937">
      - <Table>
      <EventID>567343 </EventID>
      <Event>NHL playoffs</Event>
      <Date>2007-04-21T00:00:00.000 0000-05:00</Date>
      <Time>10:00 PM</Time>
      <CategoryID>2 6</CategoryID>
      <HeadlinerID>10 1828</HeadlinerID>
      <VenueID>115920 </VenueID>
      </Table>
      </data>
      </GetListInCatego ry>
      </TopNode>
      >
      I need to pull each item out of the <TABLEnode, 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.CreateOb ject("Microsoft .XMLHTTP")
      objHTTP.open "GET","http s://secure.myxmlfee d", false
      objHTTP.send
      set objXML = server.CreateOb ject("microsoft .xmldom")
      objXML.async=fa lse
      objXML.load(obj http.responsebo dy)
      Response.Write( objxml.xml)
      >
      Can anyone tell me how to do this?
      >
      - Steve
      >
      >

      Comment

      • glbdev@gmail.com

        #4
        Re: Parse elements in XML feed

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

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

        On Apr 22, 3:22 am, "Anthony Jones" <A...@yadayaday ada.comwrote:
        <glb...@gmail.c omwrote in message
        >
        news:1177192579 .567005.51270@l 77g2000hsb.goog legroups.com...
        >
        >
        >
        >
        >
        I need to pull items out of an XML feed.
        >
        Here is an example of the XML file:
        - <TopNode>
        - <XmlFeed>
        - <GetListInCateg ory>
        - <Data Count="937">
        - <Table>
        <EventID>567343 </EventID>
        <Event>NHL playoffs</Event>
        <Date>2007-04-21T00:00:00.000 0000-05:00</Date>
        <Time>10:00 PM</Time>
        <CategoryID>2 6</CategoryID>
        <HeadlinerID>10 1828</HeadlinerID>
        <VenueID>115920 </VenueID>
        </Table>
        </data>
        </GetListInCatego ry>
        </TopNode>
        >
        I need to pull each item out of the <TABLEnode, 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.CreateOb ject("Microsoft .XMLHTTP")
        >
        Don't use the XMLHTTP in ASP it's not threadsafe. Use:-
        >
        Set objHTTP = Server.CreateOb ject("MSXML2.Se rverXMLHTTP.3.0 ")
        >
        objHTTP.open "GET","http s://secure.myxmlfee d", false
        objHTTP.send
        set objXML = server.CreateOb ject("microsoft .xmldom")
        objXML.async=fa lse
        objXML.load(obj http.responsebo dy)
        >
        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.Respons eXML
        >
        Response.Write( objxml.xml)
        >
        Can anyone tell me how to do this?
        >
        Dim oTable
        Dim oNode
        >
        Set oTable =
        objXML.selectSi ngleNode("/TopNode/XMLFeed/GetListInCatego ry/Data/Table")
        >
        For Each oNode In oTable.selectNo des("*")
        Response.Write oNode.tagName & " = " & oNode.Text & "<br />"
        Next
        >
        >
        >
        >
        >
        - Steve- Hide quoted text -
        >
        - Show quoted text -- Hide quoted text -
        >
        - Show quoted text -

        Comment

        • glbdev@gmail.com

          #5
          Re: Parse elements in XML feed

          Pupkin,

          I never heard of RSS2HTML but will look into it.

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

          On Apr 22, 3:25 am, Pupkin <spamag...@dorr k.comwrote:
          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>
          - <GetListInCateg ory>
          - <Data Count="937">
          - <Table>
          <EventID>567343 </EventID>
          <Event>NHL playoffs</Event>
          <Date>2007-04-21T00:00:00.000 0000-05:00</Date>
          <Time>10:00 PM</Time>
          <CategoryID>2 6</CategoryID>
          <HeadlinerID>10 1828</HeadlinerID>
          <VenueID>115920 </VenueID>
          </Table>
          </data>
          </GetListInCatego ry>
          </TopNode>
          >
          I need to pull each item out of the <TABLEnode, 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.CreateOb ject("Microsoft .XMLHTTP")
          objHTTP.open "GET","http s://secure.myxmlfee d", false
          objHTTP.send
          set objXML = server.CreateOb ject("microsoft .xmldom")
          objXML.async=fa lse
          objXML.load(obj http.responsebo dy)
          Response.Write( objxml.xml)
          >
          Can anyone tell me how to do this?
          >
          - Steve- Hide quoted text -
          >
          - Show quoted text -

          Comment

          Working...