Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
How to parse XML file in WRT widget using JQuery
- jquery.js must exist in the project folder and be included
We will use first an AJAX call to get the XML document. If the call was successful, the function XML_parsing_sequence will be called. In the call we will also define data type to be "xml". This will ensure that the passed parameter is in a correct form for parsing.
Functions "each" & "find" will be used in going through the document. First, the "each" is looping the tags with the given name and then "find" will be looking for a specific tag.
- If you would like to search using also by an attribute, you should add them to the XML document. See the comment in code.
- There are more tags in the XML file in this example, so you could easily try to change the code to find something else, or all of them if you like.
//Use the line below, if you have added an attribute to the XML file, e.g. <food id="1">
//Add just one extra line in between each tag to form a list
index.html - code for WRT default HTML-file
<div id="output" align="center" ></div>
The purpose for the "output" div is to display the results of the parsing, received from the basic.js.
XML file for testing
two of our famous Belgian Waffles with plenty of real maple syrup
<name>Strawberry Belgian Waffles</name>
light Belgian waffles covered with strawberries and whipped cream
<name>Berry-Berry Belgian Waffles</name>
light Belgian waffles covered with an assortment of fresh berries and whipped cream
thick slices made from our homemade sourdough bread
two eggs, bacon or sausage, toast, and our ever-popular hash browns