Welcome!

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

Reply
Regular Visitor
Posts: 1
Registered: ‎01-26-2011
My Device: Not Specified

How i can save and parsing xml?

I read many topics, but i can not  find how save xml. Please help!!!I will be very grateful!!

Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: How i can save and parsing xml?

Can you clarify your question?

 

If you are asking how to download an XML document and parse its content, I would recommend using the XmlHttpRequest object like this:

 

 

var req;
function loadData(url) {
	try {
		req = new XMLHttpRequest();
		req.onreadystatechange = handleResponse;
		req.open('GET', url, true);
		req.send(null);
	} catch(e) {
		alert('exception: ' + e.name + '; ' + e.message);
	}
}
function handleResponse() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			var xmlDoc = req.responseXML; 
			alert(xmlDoc.childNodes.length);
		} else {
			alert('Error: ' + req.statusText);
		}
	}
}

 

 

And then the WebWorks File API to save the contents of the XML document to wherever you wish to save them.

 

Cheers,

Adam

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.