Read the statement by Michael Teeuw here.
Help needed - getting informations from XML File
-
Hi to the java gurus,
i am having troubel to get to the right informations of an XML File.
I try to read a xml file of a TV set top box (Dreambox, Linux OS, Enigma2).
The xml file is provided by the webservice of the box in the same LAN (see sample below).
I already got following working reading the xml file into a variable (in node_helper.js) and sending this to the module.js.
I have to useJSON.stringify(xml)instead ofJSON.parse(xml)otherwise i got an error of some special charachters found in xml.Sample of XML
<?xml version="1.0" encoding="UTF-8"?> <e2servicelistrecursive> <e2bouquet> <e2servicereference>1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet</e2servicereference> <e2servicename>Favourites (TV)</e2servicename> <e2servicelist> <e2service> <e2servicereference>1:0:19:2B5C:41B:1:FFFF014A:0:0:0:</e2servicereference> <e2servicename>Das Erste HD</e2servicename> </e2service> <e2service> <e2servicereference>1:0:19:2B66:437:1:FFFF01C2:0:0:0:</e2servicereference> <e2servicename>ZDF HD</e2servicename> </e2service> </e2servicelist> </e2bouquet> </e2servicelistrecursive>If i send the content of xml to
console.logit shows me the right content, but the whole xml file.Now i want to get only some datas out of the xml file, but the following didnt work:
this.reference = xml.e2servicereference; this.e2servicelist = xml.e2servicelist; this.reference = xml.e2servicereference[0]; this.e2servicelist = xml.e2servicelist[0];I get an error that
xml.whateveritrytoectractis undefined.I tried to use code samples of MMM-RNV which unfortuantelly didnt work, but he is using
JSON.parse(xml)instead ofJSON.stringify(xml).Does anybody has useful tipps for me?
I am looking forward to your answers.
Best regards
AxLED
-
The easiest I have used is to conevrt to json
just add xml2json like I have used in my Bose Soundtouch module.This is the link to the js file
with
var json=xml2json(data);can use the variables quickly.
Good luck
-
@Charley
Thanks for your reply and your code inxml2json.js.
Now i can get the requested values of my xml and can move forward in developing.If somebody knows a way to directly extract datas of xml could be an optimization afterwards, to reduce code.
Regards
AxLED
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login