qx reading data from xml file

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

qx reading data from xml file

Peter
Hey,
I've just started using qx
and now fighting with the handling of a xml file.

So I'd like to read some data out of an existing xml file.
Sounds very simple, but I can not find the right handle.
What to do ?

I tried
    var req = new qx.io.request.Xhr('my.xml');
    req.addListener('success', function(e) {
       var xmlFile = e.getTarget().getResponse();   ??
    }, this);
    req.send();

This code loads the xml file and shows the plain text.
But it does not give a valid xml document to use the static function qx.xml.Element.getSingleNodeText(xmlFile, 'data').

How to connect qx.io.request.Xhr and qx.xml.Element ?
Or isn't qx.io.request.Xhr not the best tool to read data from a xml file node ?

thanks
Peter

------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: qx reading data from xml file

Dietrich Streifert
Hi Peter,

try this:

     var req = new qx.io.request.Xhr('my.xml');
     req.addListener('success', function(e) {
        var xmlFile = e.getTarget().getResponse();
        var xmlDocument = qx.xml.Document.fromString(xmlFile);
     }, this);
     req.send();

xmlDocument should contain the dom tree.

Regards
Dietrich


Am 22.12.2015 um 16:40 schrieb Greve, Peter:

> Hey,
> I've just started using qx
> and now fighting with the handling of a xml file.
>
> So I'd like to read some data out of an existing xml file.
> Sounds very simple, but I can not find the right handle.
> What to do ?
>
> I tried
>      var req = new qx.io.request.Xhr('my.xml');
>      req.addListener('success', function(e) {
>         var xmlFile = e.getTarget().getResponse();   ??
>      }, this);
>      req.send();
>
> This code loads the xml file and shows the plain text.
> But it does not give a valid xml document to use the static function qx.xml.Element.getSingleNodeText(xmlFile, 'data').
>
> How to connect qx.io.request.Xhr and qx.xml.Element ?
> Or isn't qx.io.request.Xhr not the best tool to read data from a xml file node ?
>
> thanks
> Peter
>
> ------------------------------------------------------------------------------
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: qx reading data from xml file

Peter
Hi Dietrich,

thanks for that.
qx.xml.Document.isXmlDocument(xmlDocument); gives a true now

But now I stick at reading the data.
   qx.xml.Element.selectNodes(xmlDocument, '//');
ends up in a
   Cannot read property 'selectNodes' of undefined

why 'undefined' any ideas ?

thanks Peter




------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: qx reading data from xml file

Peter
Peter <peter.greve <at> bst-international.com> writes:

>
> Hi Dietrich,
>
> thanks for that.
> qx.xml.Document.isXmlDocument(xmlDocument); gives a true now
>
> But now I stick at reading the data.
>    qx.xml.Element.selectNodes(xmlDocument, '//');
> ends up in a
>    Cannot read property 'selectNodes' of undefined
>
> why 'undefined' any ideas ?
>
> thanks Peter
>
> --------------------------------------------------------------------------
----
>

hi again

I got the data when using :

  var xmlNodes = xmlDocument.getElementsByTagName();
  var data = xmlNodes['tagName'].attributes.getNamedItem('itemName').value;

But isn't there a solution by just using the qx.xml stuff ?
qx.xml.Element.getSingleNodeText() sounds very good.
Could it shorten the way and should give the same result?

regards
Peter


------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: qx reading data from xml file

Dietrich Streifert
In reply to this post by Peter
Hi Peter,

did you re-generate your app using

     generate.py source

Usually the class loader only loads those classes needed.

If you use some new classes (I suspect qx.xm.Element is new in your
code) after you call generate.py, the qx loader is not aware of that
class, thus not loading it.



Am 23.12.2015 um 09:19 schrieb Peter:

> Hi Dietrich,
>
> thanks for that.
> qx.xml.Document.isXmlDocument(xmlDocument); gives a true now
>
> But now I stick at reading the data.
>     qx.xml.Element.selectNodes(xmlDocument, '//');
> ends up in a
>     Cannot read property 'selectNodes' of undefined
>
> why 'undefined' any ideas ?
>
> thanks Peter
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Loading...