Loading ...
Sorry, an error occurred while loading the content.

RE: [svg-developers] Find Item in XML

Expand Messages
  • Gergely Hajdu
    Hi, I would suggest you to use Digester : http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.html This is a very good introduction. By
    Message 1 of 10 , Dec 1, 2003
    View Source
    • 0 Attachment
      Hi,

      I would suggest you to use Digester :

      http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.html

      This is a very good introduction. By reading this, I could use it quite
      quickly.

      Regards
      /Gergely
      -----Original Message-----
      From: bobhunter7 [mailto:bhunter@...]
      Sent: Saturday, November 29, 2003 4:41 AM
      To: svg-developers@yahoogroups.com
      Subject: [svg-developers] Find Item in XML


      I have an application that loads an xml document and displays the
      text from the xml document in the svg document. But, I think I'm
      using an innefficient method for locating the desired record in the
      xml document.

      The xml document looks likes this:
      <InfoList>
      <obj id="0">
      <info>Info to display</info>
      </obj>

      <obj id="1">
      <info>More info here</info>
      </obj>

      <obj id="2">
      <info>Still more</info>
      </obj>
      </InfoList>

      In reality, there may be hundreds of entries in the document.

      So, if I need to find the one passed to the function as n, here's
      what I do:

      xmlDoc.load(xmlFile) // Loads the xml document
      all = xmlDoc.getElementsByTagName("info"); //get all info elements
      pick = all.item(n); //pick's the nth one in the list
      pick.text is the text from the element that I put in the display.

      This works, but only because I've ordered the elements by number (id
      = '3') and pick the nth one in the list. What I'd prefer to do is
      to use more meaningful ids and do

      xmlDoc.getElementById(meaningfulID)

      But, this is apprently not acceptable to the ASV 3 (returns an error
      that this function doesn't exist).

      So, I got clever and did a xpath-like query:

      pick = xmlDoc.selectNodes("//obj[@id=meaningfulID]/info")

      This returns results, but I'm not able get the text out of it. I've
      tried pick.text, pick.firstChild.text, pick.nodeValue, etc.

      Surely there is an easy javascript way to do the equivalent of
      getElementById in an xml file!

      Anyone have an idea?

      Thanks,

      Bob



      Yahoo! Groups Sponsor
      ADVERTISEMENT




      -----
      To unsubscribe send a message to:
      svg-developers-unsubscribe@yahoogroups.com
      -or-
      visit http://groups.yahoo.com/group/svg-developers and click "edit my
      membership"
      ----

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      [Non-text portions of this message have been removed]
    • Chris Peto
      Hi, Is this xml doc and svg doc? If so, then you need to get the getSVGDocument() and then use svgDoc.getElementById(meaningfulID) . Mit freundlichen
      Message 2 of 10 , Dec 1, 2003
      View Source
      • 0 Attachment
        Hi,

        Is this xml doc and svg doc? If so, then you need to get the
        getSVGDocument() and then use svgDoc.getElementById(meaningfulID)
        .

        Mit freundlichen Gru?en/Regards
        Chris Peto
        Freelance System Development
        ------------------------------------
        Resource Solutions
        Germany
        Mobile: +49 (0) 173 308 7843
        Tel:+49(0) 6103 80 21 98
        Web: http://www.resource-solutions.de
        SVG editor: http://www.resource-solutions.de/svgeditor.html
        mailto:CPeto@...
        ------------------------------------
        Member of: SPARK - SVG Programmers' Application Resource Kit
        SVG site: http://www.schemasoft.org/svg/main.svg
        HTML site: http://www.schemasoft.org/





        -----Original Message-----
        From: Gergely Hajdu [mailto:ghajdu@...]
        Sent: Montag, 1. Dezember 2003 09:46
        To: svg-developers@yahoogroups.com
        Subject: RE: [svg-developers] Find Item in XML


        Hi,

        I would suggest you to use Digester :


        http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.html

        This is a very good introduction. By reading this, I could use it quite
        quickly.

        Regards
        /Gergely
        -----Original Message-----
        From: bobhunter7 [mailto:bhunter@...]
        Sent: Saturday, November 29, 2003 4:41 AM
        To: svg-developers@yahoogroups.com
        Subject: [svg-developers] Find Item in XML


        I have an application that loads an xml document and displays the
        text from the xml document in the svg document. But, I think I'm
        using an innefficient method for locating the desired record in the
        xml document.

        The xml document looks likes this:
        <InfoList>
        <obj id="0">
        <info>Info to display</info>
        </obj>

        <obj id="1">
        <info>More info here</info>
        </obj>

        <obj id="2">
        <info>Still more</info>
        </obj>
        </InfoList>

        In reality, there may be hundreds of entries in the document.

        So, if I need to find the one passed to the function as n, here's
        what I do:

        xmlDoc.load(xmlFile) // Loads the xml document
        all = xmlDoc.getElementsByTagName("info"); //get all info elements
        pick = all.item(n); //pick's the nth one in the list
        pick.text is the text from the element that I put in the display.

        This works, but only because I've ordered the elements by number (id
        = '3') and pick the nth one in the list. What I'd prefer to do is
        to use more meaningful ids and do

        xmlDoc.getElementById(meaningfulID)

        But, this is apprently not acceptable to the ASV 3 (returns an error
        that this function doesn't exist).

        So, I got clever and did a xpath-like query:

        pick = xmlDoc.selectNodes("//obj[@id=meaningfulID]/info")

        This returns results, but I'm not able get the text out of it. I've
        tried pick.text, pick.firstChild.text, pick.nodeValue, etc.

        Surely there is an easy javascript way to do the equivalent of
        getElementById in an xml file!

        Anyone have an idea?

        Thanks,

        Bob



        Yahoo! Groups Sponsor
        ADVERTISEMENT




        -----
        To unsubscribe send a message to:
        svg-developers-unsubscribe@yahoogroups.com
        -or-
        visit http://groups.yahoo.com/group/svg-developers and click "edit my
        membership"
        ----

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


        [Non-text portions of this message have been removed]


        Yahoo! Groups Sponsor
        ADVERTISEMENT




        -----
        To unsubscribe send a message to:
        svg-developers-unsubscribe@yahoogroups.com
        -or-
        visit http://groups.yahoo.com/group/svg-developers and click "edit my
        membership"
        ----

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


        [Non-text portions of this message have been removed]
      • Bob Hunter
        Actually, this was a XML doc loaded by external javascript. Data from the xml document is shown in the svg by way of the external javascript. The problem
        Message 3 of 10 , Dec 1, 2003
        View Source
        • 0 Attachment
          Actually, this was a XML doc loaded by external javascript. Data from the
          xml document is shown in the svg by way of the external javascript. The
          problem was not how to show in the svg, but how to find the data in the xml
          document without having to loop through all the nodes looking for a node
          with an id that matches the desired one.

          Bob

          -----Original Message-----
          From: Chris Peto [mailto:CPeto@...]
          Sent: Monday, December 01, 2003 3:51 AM
          To: svg-developers@yahoogroups.com
          Subject: RE: [svg-developers] Find Item in XML

          Hi,

          Is this xml doc and svg doc? If so, then you need to get the
          getSVGDocument() and then use svgDoc.getElementById(meaningfulID)
          .

          Mit freundlichen Gru?en/Regards
          Chris Peto
          Freelance System Development
          ------------------------------------
          Resource Solutions
          Germany
          Mobile: +49 (0) 173 308 7843
          Tel:+49(0) 6103 80 21 98
          Web: http://www.resource-solutions.de
          SVG editor: http://www.resource-solutions.de/svgeditor.html
          mailto:CPeto@...
          ------------------------------------
          Member of: SPARK - SVG Programmers' Application Resource Kit
          SVG site: http://www.schemasoft.org/svg/main.svg
          HTML site: http://www.schemasoft.org/





          -----Original Message-----
          From: Gergely Hajdu [mailto:ghajdu@...]
          Sent: Montag, 1. Dezember 2003 09:46
          To: svg-developers@yahoogroups.com
          Subject: RE: [svg-developers] Find Item in XML


          Hi,

          I would suggest you to use Digester :


          http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.html

          This is a very good introduction. By reading this, I could use it quite
          quickly.

          Regards
          /Gergely
          -----Original Message-----
          From: bobhunter7 [mailto:bhunter@...]
          Sent: Saturday, November 29, 2003 4:41 AM
          To: svg-developers@yahoogroups.com
          Subject: [svg-developers] Find Item in XML


          I have an application that loads an xml document and displays the
          text from the xml document in the svg document. But, I think I'm
          using an innefficient method for locating the desired record in the
          xml document.

          The xml document looks likes this:
          <InfoList>
          <obj id="0">
          <info>Info to display</info>
          </obj>

          <obj id="1">
          <info>More info here</info>
          </obj>

          <obj id="2">
          <info>Still more</info>
          </obj>
          </InfoList>

          In reality, there may be hundreds of entries in the document.

          So, if I need to find the one passed to the function as n, here's
          what I do:

          xmlDoc.load(xmlFile) // Loads the xml document
          all = xmlDoc.getElementsByTagName("info"); //get all info elements
          pick = all.item(n); //pick's the nth one in the list
          pick.text is the text from the element that I put in the display.

          This works, but only because I've ordered the elements by number (id
          = '3') and pick the nth one in the list. What I'd prefer to do is
          to use more meaningful ids and do

          xmlDoc.getElementById(meaningfulID)

          But, this is apprently not acceptable to the ASV 3 (returns an error
          that this function doesn't exist).

          So, I got clever and did a xpath-like query:

          pick = xmlDoc.selectNodes("//obj[@id=meaningfulID]/info")

          This returns results, but I'm not able get the text out of it. I've
          tried pick.text, pick.firstChild.text, pick.nodeValue, etc.

          Surely there is an easy javascript way to do the equivalent of
          getElementById in an xml file!

          Anyone have an idea?

          Thanks,

          Bob



          Yahoo! Groups Sponsor
          ADVERTISEMENT




          -----
          To unsubscribe send a message to:
          svg-developers-unsubscribe@yahoogroups.com
          -or-
          visit http://groups.yahoo.com/group/svg-developers and click "edit my
          membership"
          ----

          Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


          [Non-text portions of this message have been removed]


          Yahoo! Groups Sponsor
          ADVERTISEMENT




          -----
          To unsubscribe send a message to:
          svg-developers-unsubscribe@yahoogroups.com
          -or-
          visit http://groups.yahoo.com/group/svg-developers and click "edit my
          membership"
          ----

          Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


          [Non-text portions of this message have been removed]



          -----
          To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
          -or-
          visit http://groups.yahoo.com/group/svg-developers and click "edit my
          membership"
          ----

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        • Mathias FATENE
          Hi, This means that your need something faster than an xml parser. Every method you use will first need to read data. To access a method like seek in an xml
          Message 4 of 10 , Dec 1, 2003
          View Source
          • 0 Attachment
            Hi,
            This means that your need something faster than an xml parser.
            Every method you use will first need to read data. To access a method like
            seek in an xml document, you nead xmlquery, xsl, or something like that.

            Every parser will use something like a loop to find th ematching element.
            RegExp can solve your problem, but you will always read all the file to look
            for just ONE element.

            But i have an advise for you.

            To be faster than everything else, create a file named by a city and
            containing the description for the city.
            Use my code, and just parseXML the data.content of the file used in
            parameter of the onmouseover event.


            Mathias

            -----Original Message-----
            From: Bob Hunter [mailto:bhunter@...]
            Sent: Monday, December 01, 2003 4:00 PM
            To: svg-developers@yahoogroups.com
            Subject: RE: [svg-developers] Find Item in XML


            Actually, this was a XML doc loaded by external javascript. Data from the
            xml document is shown in the svg by way of the external javascript. The
            problem was not how to show in the svg, but how to find the data in the xml
            document without having to loop through all the nodes looking for a node
            with an id that matches the desired one.

            Bob

            -----Original Message-----
            From: Chris Peto [mailto:CPeto@...]
            Sent: Monday, December 01, 2003 3:51 AM
            To: svg-developers@yahoogroups.com
            Subject: RE: [svg-developers] Find Item in XML

            Hi,

            Is this xml doc and svg doc? If so, then you need to get the
            getSVGDocument() and then use svgDoc.getElementById(meaningfulID)
            .

            Mit freundlichen Gru?en/Regards
            Chris Peto
            Freelance System Development
            ------------------------------------
            Resource Solutions
            Germany
            Mobile: +49 (0) 173 308 7843
            Tel:+49(0) 6103 80 21 98
            Web: http://www.resource-solutions.de
            SVG editor: http://www.resource-solutions.de/svgeditor.html
            mailto:CPeto@...
            ------------------------------------
            Member of: SPARK - SVG Programmers' Application Resource Kit
            SVG site: http://www.schemasoft.org/svg/main.svg
            HTML site: http://www.schemasoft.org/





            -----Original Message-----
            From: Gergely Hajdu [mailto:ghajdu@...]
            Sent: Montag, 1. Dezember 2003 09:46
            To: svg-developers@yahoogroups.com
            Subject: RE: [svg-developers] Find Item in XML


            Hi,

            I would suggest you to use Digester :


            http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.html

            This is a very good introduction. By reading this, I could use it quite
            quickly.

            Regards
            /Gergely
            -----Original Message-----
            From: bobhunter7 [mailto:bhunter@...]
            Sent: Saturday, November 29, 2003 4:41 AM
            To: svg-developers@yahoogroups.com
            Subject: [svg-developers] Find Item in XML


            I have an application that loads an xml document and displays the
            text from the xml document in the svg document. But, I think I'm
            using an innefficient method for locating the desired record in the
            xml document.

            The xml document looks likes this:
            <InfoList>
            <obj id="0">
            <info>Info to display</info>
            </obj>

            <obj id="1">
            <info>More info here</info>
            </obj>

            <obj id="2">
            <info>Still more</info>
            </obj>
            </InfoList>

            In reality, there may be hundreds of entries in the document.

            So, if I need to find the one passed to the function as n, here's
            what I do:

            xmlDoc.load(xmlFile) // Loads the xml document
            all = xmlDoc.getElementsByTagName("info"); //get all info elements
            pick = all.item(n); //pick's the nth one in the list
            pick.text is the text from the element that I put in the display.

            This works, but only because I've ordered the elements by number (id
            = '3') and pick the nth one in the list. What I'd prefer to do is
            to use more meaningful ids and do

            xmlDoc.getElementById(meaningfulID)

            But, this is apprently not acceptable to the ASV 3 (returns an error
            that this function doesn't exist).

            So, I got clever and did a xpath-like query:

            pick = xmlDoc.selectNodes("//obj[@id=meaningfulID]/info")

            This returns results, but I'm not able get the text out of it. I've
            tried pick.text, pick.firstChild.text, pick.nodeValue, etc.

            Surely there is an easy javascript way to do the equivalent of
            getElementById in an xml file!

            Anyone have an idea?

            Thanks,

            Bob



            Yahoo! Groups Sponsor
            ADVERTISEMENT




            -----
            To unsubscribe send a message to:
            svg-developers-unsubscribe@yahoogroups.com
            -or-
            visit http://groups.yahoo.com/group/svg-developers and click "edit my
            membership"
            ----

            Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


            [Non-text portions of this message have been removed]


            Yahoo! Groups Sponsor
            ADVERTISEMENT




            -----
            To unsubscribe send a message to:
            svg-developers-unsubscribe@yahoogroups.com
            -or-
            visit http://groups.yahoo.com/group/svg-developers and click "edit my
            membership"
            ----

            Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


            [Non-text portions of this message have been removed]



            -----
            To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
            -or-
            visit http://groups.yahoo.com/group/svg-developers and click "edit my
            membership"
            ----

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





            -----
            To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
            -or-
            visit http://groups.yahoo.com/group/svg-developers and click "edit my
            membership"
            ----

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          Your message has been successfully submitted and would be delivered to recipients shortly.