Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Posts: 17
Registered: ‎02-13-2012
My Device: BOLD 9900
My Carrier: Airtel

how we can parse an XML in HTML5

how we can parse an XML in HTML5 

Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: how we can parse an XML in HTML5

Hi! You must use javascript to parse the xml.


Here are a few links to get you started: 


//Perform when the document is ready/loaded/rendered
   //Asynchronously retrieve the xml file contents		
      type: "GET",				
      url: "sites.xml",				
      dataType: "xml",				
      success: function(xml) { //Upon successful retrieval
         //Iterate through the all the nodes/items
         $(xml).find('site').each(function(){ //For each item, perform the following						
            //Read each child node and associate the values with a variable
            var id = $(this).attr('id'); //Find an attribute within the "site" node/element						
            var title = $(this).find('title').text(); //Find the child element of "site" called title						
            var url = $(this).find('url').text(); //Find the child element of "site" called title						
            //Write out a custom link with the values above
            $('<div class="items" id="link_'+id+'"></div>').html('<a href="'+url+'">'+title+'</a>').appendTo('#page-wrap');
            //Establish the "desc" node/element as the this value below, to be referenced fro child nodes/elements
               var brief = $(this).find('brief').text();
               var long = $(this).find('long').text();
               $('<div class="brief"></div>').html(brief).appendTo('#link_'+id);
               $('<div class="long"></div>').html(long).appendTo('#link_'+id);



Good luck!Smiley Wink