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

Re: Dealing with XML DOM (Newbie)

Expand Messages
  • piaffra_woods
    Thank you, it works that way. Nevertheless i ask myself why, because, i thought, i am already in the node , so why firstChild. But that´s certainly my lack
    Message 1 of 22 , Mar 1, 2006
    • 0 Attachment
      Thank you, it works that way. Nevertheless i ask myself why, because,
      i thought, i am already in "the node", so why firstChild. But that´s
      certainly my lack of dom-knowledge.

      --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...> wrote:
      >
      > --- In ydn-javascript@yahoogroups.com, "piaffra_woods"
      > <piaffra_woods@> wrote:
      >
      > > <script type="text/javascript"><!--
      > > var responseSuccess = function(o){
      > > var scheissdreck = o.responseXML;
      > > var children = scheissdreck.documentElement.childNodes;
      > > var autorNode = false;
      > > var titelNode = false;
      > > for (var i=0; i<children.length; i++) {
      > > // if this node is an element node
      > > if (children[i].nodeType == 1) {
      > > if (children[i].nodeName == 'autor') {
      > > autorNode = children[i].firstChild;
      > > }
      > > else if (children[i].nodeName == 'titel') {
      > > titelNode = children[i];
      > > }
      > > } // end if element
      > > } // end for
      > > alert('Titel: ' + titelNode.data); // + '
      Autor'.autorNode.nodeValue);
      > > }
      >
      > Try replacing your *else if* with this:
      >
      > else if(children[i].nodeName == 'titel'){
      > titelNode = children[i].firstChild;
      > // this should return Tanztherapie
      > alert(titelNode.nodeValue);
      > }
      >
      > Regards,
      > Thomas
      >
      > > --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@> wrote:
      > > >
      > > > --- In ydn-javascript@yahoogroups.com, Ken Robinson <kenrbnsn@>
      wrote:
      > > > >
      > > > > At 09:50 AM 2/28/2006, piaffra_woods wrote:
      > > > > >See, this is the problem. Enough stuff out there regarding Dom
      > - HTML
      > > > > >but i can´t find a neat howto about "standard" dom -methods and
      > > > > >(non-html) xml. It is quite absurd (or its my lack of
      > > > > >javascript-knowledge) i try since tree days to get the value
      from a
      > > > > >dom-element-node, where i can get the nodeName without any
      trouble.
      > > > > >Maybe someone has an example with yahoos transport library,
      > > > > >xml-response and parsing trough this response.
      > > > >
      > > > > Unfortunately, as I discovered, the xml-response
      > > > > from the Yahoo libraries has already been
      > > > > transformed to something else and none of the "standard" methods
      > work.
      > > > >
      > > > > The Yahoo developers really need to document the
      > > > > structures of these items, give us routines to
      > > > > parse them, or return a regular XML object that
      > > > > can be parsed with the "standard" methods.
      > > > >
      > > > > Ken
      > > > >
      > > > Actually, the connection manager does not transform or modify the
      > > > responseXML values from the native object.
      > > >
      > > > If you find the responseXML property is null, you are expecting XML,
      > > > did your resource reply with a MIME header of "text/xml"?
      > > >
      > > > Regards,
      > > > Thomas
      > > >
      > >
      >
    • Nige White
      ... The titel node is an Element, *not* a text node. It represents the tag. Anything between that tag and its matching end tag *including text* is a
      Message 2 of 22 , Mar 1, 2006
      • 0 Attachment
        piaffra_woods wrote:

        > Thank you, it works that way. Nevertheless i ask myself why, because,
        > i thought, i am already in "the node", so why firstChild. But that´s
        > certainly my lack of dom-knowledge.


        The titel node is an Element, *not* a text node.

        It represents the <titel> tag. Anything between that tag and its
        matching end tag *including text* is a child node of that element.


        _____________________________________________________________________
        This message has been checked for all known viruses. Virus scanning
        powered by Messagelabs http://www.messagelabs.com For more information
        e-mail : hostmaster@...
      Your message has been successfully submitted and would be delivered to recipients shortly.