including xml inline html documents

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

    including xml inline html documents

    I was wondering if it is possible to include a xml structure in your html
    document.

    For example given the below snippet the function "dothis()" will return 0
    and "dothat()" will return 1.

    If I can use xml in html I should be returning 1 for both functions.

    Thanks,

    Mike

    <script>
    function dothis()
    {
    var xxx = document.getEle mentById('xmlid ');
    alert(xxx.child Nodes.length);
    }
    function dothat()
    {
    var xxx = document.getEle mentById('tblid ');
    alert(xxx.child Nodes.length);
    }
    </script>

    <xml id="xmlid">
    <data>
    <first>abc</first>
    </data>
    </xml>

    <table id="tblid">
    <tr>
    <td>abc</td>
    </tr>
    </table>


  • VK

    #2
    Re: including xml inline html documents

    <xml> is just a wrapper for Microsoft Data Island.
    Do start working with the XML data itself, you have to go one more level
    down, and after that use the standard DOM methods for XML objects.

    From your example:

    function dothis() {
    var xxx = xmlid.XMLDocume nt.selectSingle Node('data/first');
    alert(xxx.text) ;
    }
    ....
    <xml id="xmlid">
    <data>
    <first>abc</first>
    </data>
    </xml>



    Comment

    • Michael Hill

      #3
      Re: including xml inline html documents

      "VK" <schools_ring@y ahoo.com> wrote in message
      news:419f2085$0 $161$9b622d9e@n ews.freenet.de. ..[color=blue]
      > <xml> is just a wrapper for Microsoft Data Island.
      > Do start working with the XML data itself, you have to go one more level
      > down, and after that use the standard DOM methods for XML objects.
      >
      > From your example:
      >
      > function dothis() {
      > var xxx = xmlid.XMLDocume nt.selectSingle Node('data/first');
      > alert(xxx.text) ;
      > }
      > ...
      > <xml id="xmlid">
      > <data>
      > <first>abc</first>
      > </data>
      > </xml>
      >
      >[/color]
      vk, thanks for that start. using this script:

      var myxml = xmlid.XMLDocume nt;
      var myroot = myxml.documentE lement;
      var myNodes = myroot.childNod es;
      for ( i=0; i<myNodes.lengt h; i++ )
      {
      alert(myNodes.i tem(i).firstChi ld.nodeValue);
      }

      and this xml

      <xml id="xmlid">
      <data>
      <first>abc</first><second>x yz</second>
      </data>
      </xml>

      I get "abc", "xyz" as predicted, but when I change my xml adding another
      record it does not.

      <xml id="xmlid">
      <data>
      <first>abc</first><second>x yz</second>
      </data>
      <data>
      <first>def</first><second>d fr</second>
      </data>
      </xml>

      i can't get my node pointer positioned correctly.

      Mike


      Comment

      • Martin Honnen

        #4
        Re: including xml inline html documents



        Michael Hill wrote:

        [color=blue]
        > but when I change my xml adding another
        > record it does not.
        >
        > <xml id="xmlid">
        > <data>
        > <first>abc</first><second>x yz</second>
        > </data>
        > <data>
        > <first>def</first><second>d fr</second>
        > </data>
        > </xml>
        >
        > i can't get my node pointer positioned correctly.[/color]

        Well it is called XML data island as you are supposed to have XML in
        there and XML needs to have exactly one root element to contain all
        other elements e.g.
        <xml id="xmlid">
        <root>
        <data>
        <first>abc</first><second>x yz</second>
        </data>
        <data>
        <first>def</first><second>d fr</second>
        </data>
        </root>
        </xml>

        --

        Martin Honnen

        Comment

        Working...