Does UIWebView allow XML DOM Parser?

By : bgoers

I am not quite sure, and haven't been able to find anything.

Using stringByEvaluatingJavascriptFromString:, I have been able to manipulate javascript in my page from objective-c. However, I now want to populate form fields by passing raw xml data from the iOS UIWebView into the html file (which is local to the app), and then using the parsed data.

Looking over the W3C document, it seems I need to do something like:

parser = new DOMParser();
xmlString = parser.parseFromString(txt, "text/xml");

Which should return a DOM object from the XML (which here is represented by the string txt). I should then be able to access the properties of this DOM object from


Assuming we have an XML node such as:


However, this doesn't seem to work. Setting that nodeValue into a string and returning it returns nil. Likewise, form fields are not populated.

My question, then, is whether the embedded browser in an app can utilize the DOM Parser - and if it can, what syntax I might use to access values from it?

By : bgoers

Solved, unfortunately very fast. It seems that when setting form fields you need to specify VALUE instead of innerhtml.

so I did:

document.getElementById("FIELDID").value = 

Also, I had the parameters passed to the DOM parser wrong - it is "text/xml" for the second parameter.

By : bgoers

This video can help you solving your question :)
By: admin