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

Re: [ydn-javascript] Re: Dealing with XML DOM (Newbie)

Expand Messages
  • Matt Warden
    ... Hash: SHA1 ... It s standard DOM, which means if you really want to, you *could* think in PHP : http://php.net/domxml e.g.:
    Message 1 of 22 , Feb 28, 2006
    • 0 Attachment
      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Ken Robinson wrote:
      > When it is shown like that, it's easy, but the problem here is that not
      > all of us are expert Javascript coders. I, for one, am very good at PHP4
      > and very weak at Javascript. When I write a script I "think in PHP" and
      > the try to translate that to Javascrpt. A lot of the concepts just don't
      > translate well.
      >
      > If you could point to a document or web site where the structures are
      > defined it would be helpful.

      It's standard DOM, which means if you really want to, you *could* "think
      in PHP":

      http://php.net/domxml

      e.g.: http://php.net/domdocument-get-elements-by-tagname

      - --
      Matt Warden
      Miami University
      Oxford, OH, USA
      http://mattwarden.com


      This email proudly and graciously contributes to entropy.
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.1 (GNU/Linux)
      Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

      iD8DBQFEBMEarI3LObhzHRMRAl2eAJ45ktRrg7epdG64Y8O5nFSvc5n/tgCfaDMH
      EI2/nkfQ62XT+brz2hUlEDE=
      =3ek7
      -----END PGP SIGNATURE-----
    • 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 2 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 3 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.