Extracting data from XML document

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken

    Extracting data from XML document


    What software is required to extract certain data from an XML
    document?
  • Ken

    #2
    Re: Extracting data from XML document


    What I mean by the below question is rather : What software is
    required to extract certain data from an XML document that is served
    from another website?

    On Thu, 27 Nov 2003 03:15:22 GMT, learnhubremthis only@singnet.co m.sg
    (Ken) wrote:
    [color=blue]
    >
    >What software is required to extract certain data from an XML
    >document?[/color]

    Comment

    • Martin Honnen

      #3
      Re: Extracting data from XML document



      Ken wrote:[color=blue]
      >
      > On Thu, 27 Nov 2003 03:15:22 GMT, learnhubremthis only@singnet.co m.sg
      > (Ken) wrote:
      >
      >
      > What I mean by the below question is rather : What software is
      > required to extract certain data from an XML document that is served
      > from another website?
      >[color=green]
      >>What software is required to extract certain data from an XML
      >>document?[/color][/color]

      XML parsers know how to load files via HTTP so all you need is an XML
      parser. Check http://xml.apache.org/ for XML parsers.
      --

      Martin Honnen


      Comment

      • Patrick TJ McPhee

        #4
        Re: Extracting data from XML document

        In article <3fc6707b.64184 50@news.singnet .com.sg>,
        Ken <learnhubremthi sonly@singnet.c om.sg> wrote:

        % What I mean by the below question is rather : What software is
        % required to extract certain data from an XML document that is served
        % from another website?

        What do you want to do? There are programs which can extract data
        and stick it a relational database. There are programs which can
        extract data and write it to a flat file. There are libraries which
        can feed data directly to an application you've written.

        --

        Patrick TJ McPhee
        East York Canada
        ptjm@interlog.c om

        Comment

        • user@domain.invalid

          #5
          Re: Extracting data from XML document


          [color=blue]
          > What software is
          > required to extract certain data from an XML document that is served
          > from another website?[/color]

          You can use XSLT's document() function.

          Code example:

          <xsl:template match="foo">
          <xsl:apply-templates select="documen t('http://www.theserver.c om/foo.xml')"/>
          </xsl:template>


          Devon

          Comment

          • Ken

            #6
            Re: Extracting data from XML document


            I want to extract the data and put them into an access database. But
            do tell me more about the other programs like libraries which can feed
            data directl y to an application I have written.

            Tks

            On Thu, 27 Nov 2003 16:57:34 +0100 (MET), ptjm@interlog.c om (Patrick
            TJ McPhee) wrote:
            [color=blue]
            >In article <3fc6707b.64184 50@news.singnet .com.sg>,
            >Ken <learnhubremthi sonly@singnet.c om.sg> wrote:
            >
            >% What I mean by the below question is rather : What software is
            >% required to extract certain data from an XML document that is served
            >% from another website?
            >
            >What do you want to do? There are programs which can extract data
            >and stick it a relational database. There are programs which can
            >extract data and write it to a flat file. There are libraries which
            >can feed data directly to an application you've written.[/color]

            Comment

            • Ken

              #7
              Re: Extracting data from XML document

              Thanks Devon. I use your method and can't seem to return the required
              elements. Can you tell me what's wrong with the code below? The code
              is adapted from http://www.w3schools.com/xsl/xsl_value_of.asp


              --------------- code start here -------------------

              <?xml version="1.0" encoding="ISO-8859-1"?>
              <xsl:styleshe et version="1.0"
              xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

              <xsl:template match="/">
              <xsl:apply-templates
              select="documen t('http://www.w3schools.c om/xsl/cdcatalog.xml') "/>
              </xsl:template>

              <html>
              <body>
              <h2>My CD Collection</h2>
              <table border="1">
              <tr bgcolor="#9acd3 2">
              <th>Title</th>
              <th>Artist</th>
              </tr>
              <tr>
              <td><xsl:valu e-of select="catalog/cd/title"/></td>
              <td><xsl:valu e-of select="catalog/cd/artist"/></td>
              </tr>
              </table>
              </body>
              </html>
              </xsl:template>
              </xsl:stylesheet>

              -------------------- code end here -------------------


              On Thu, 27 Nov 2003 18:33:54 GMT, user@domain.inv alid wrote:
              [color=blue]
              >
              >[color=green]
              >> What software is
              >> required to extract certain data from an XML document that is served
              >> from another website?[/color]
              >
              >You can use XSLT's document() function.
              >
              >Code example:
              >
              ><xsl:templat e match="foo">
              ><xsl:apply-templates select="documen t('http://www.theserver.c om/foo.xml')"/>
              ></xsl:template>
              >
              >
              >Devon[/color]

              Comment

              • Andy Dingley

                #8
                Re: Extracting data from XML document

                On Fri, 28 Nov 2003 04:02:51 GMT, learnhubremthis only@singnet.co m.sg
                (Ken) wrote:
                [color=blue]
                >Thanks Devon. I use your method and can't seem to return the required
                >elements. Can you tell me what's wrong with the code below? The code
                >is adapted from http://www.w3schools.com/xsl/xsl_value_of.asp[/color]

                Try this:

                <?xml version="1.0" encoding="ISO-8859-1"?>
                <xsl:styleshe et version="1.0"
                xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

                <xsl:variable name="doc"
                select="documen t('http://www.w3schools.c om/xsl/cdcatalog.xml') "/>

                <xsl:template match="/">

                <html><body>
                <h2>My CD Collection</h2>

                <table border="1">
                <tr bgcolor="#9acd3 2"><th>Title </th><th>Artist</th></tr>

                <xsl:for-each select="$doc/catalog/cd" >
                <tr>
                <td><xsl:valu e-of select="./title"/></td>
                <td><xsl:valu e-of select="./artist"/></td>
                </tr>
                </xsl:for-each>

                </table>
                </body></html>
                </xsl:template>

                </xsl:stylesheet>



                If you want to see it quickly in client-side IE, save it as
                xsl_document.xs l and try browsing the following xml document

                <?xml version="1.0" encoding="ISO-8859-1"?>
                <?xml-stylesheet type="text/xsl" href="xsl_docum ent.xsl" ?>

                <foo />

                --
                Die Gotterspammerun g - Junkmail of the Gods

                Comment

                • Patrick TJ McPhee

                  #9
                  Re: Extracting data from XML document

                  In article <3fc6c028.76016 649@news.singne t.com.sg>,
                  Ken <learnhubremthi sonly@singnet.c om.sg> wrote:

                  % I want to extract the data and put them into an access database. But
                  % do tell me more about the other programs like libraries which can feed
                  % data directl y to an application I have written.

                  I was thinking specifically of XML parsers, and in particular parsers
                  which have XPath implementations . There are many of them floating around.
                  --

                  Patrick TJ McPhee
                  East York Canada
                  ptjm@interlog.c om

                  Comment

                  Working...