Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8083737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:34:13+00:00 2026-06-05T17:34:13+00:00

I am having some trouble parsing xform xml with javascript. The structure of the

  • 0

I am having some trouble parsing xform xml with javascript.

The structure of the root of the xml is:

<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ex="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
  <h:head>
    <h:title>Phonegap Survey</h:title>        
  </h:head>
  <h:body>A ton more tags here</h:body>
</h:html>

I am using firefox (v.12) to develop and trying to deploy to phonegap/cordova on android. I am getting the data from an odk server using jquery ajax. I am specifiying dataType: 'xml' and it is responding with a document object as expected. In firefox I have written an app that presents data from this xml to the user. I am using built in javascript DOM functions like:

var title = surveyXML.getElementsByTagName('h:title')[0].firstChild.data
var body = surveyXML.getElementsByTagName('h:body')[0];
var text = surveyXML.getElementsByTagName('text')

I have written the full app (and it works fine) using these methods. But now that I have copied my files over to phonegap (running cordovo 1.7.0, on android emulator 2.3) on eclipse none of the DOM calls are returning elements!! I get something like:

05-31 13:21:28.686: D/CordovaLog(841): file:///android_asset/www/formcontroller.js:
line 159 : TypeError: Result of expression 'body' [undefined] is not an object.

For all the calls. I have verified that the device has the correct xml (it’s not empty or anything)

So having to get this done I tried to use jQuery to navigate the document object hoping it knew something I didn’t. Using calls like:

$(surveyXML).find('title');
$(surveyXML).find('h:title')

do not work at all. But tags without the h: prefix work fine, if I were to search for $(surveyXML).find('text') it returns all text elements as expected.

Seeing as the root elements are <html> I tried to specify dataType: html (just to try it even though the document is clearly marked as <?xml version="1.0"?>) and jquery is unable to parse it, as expected.

So I am wondering: How can I parse this XML cross platform so that it can work both in a browser and phonegap. And, supposing that it can’t work in both using the same DOM manipulation functions, how can I at least make it work in phonegap??

As always any help is appreciated. Thank you.

EDIT: For right Now I am just manually referencing the exact locations of the elements like to get to body I am going xml.firstChild.children[1]. Because I am underdeadline. I def feel like there should be a way to use getElementsByTagName still. ty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:34:15+00:00Added an answer on June 5, 2026 at 5:34 pm

    This has been unanswered for 2 weeks so I am just posting what I did.

    For right Now I am just manually referencing the exact locations of the elements like to get to body I am going xml.firstChild.children[1].

    So all I did was not search for tags with the namespace and just reference them directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble parsing malformed XML in PHP. In particular I'm querying a
My problem is specifically about some trouble I'm having parsing an Inkscape (XML) file,
I'm having some trouble parsing an XML file with ColdFusion. I've double, triple-checked the
I'm having some trouble parsing a *.CSV file in windows server 2008 64bit version.
I am having trouble parsing some returned XML using this command: XML::Parser.string(xml_string).parse Here is
I'm having some trouble parsing a JSON that I obtain from my DB to
I'm having some trouble passing an array from controller to a javascript in a
I'm parsing some IIS server logs (with LogParser) and I'm having a little trouble
I was having some trouble with my parsing function so I put some cout
I'm having some trouble using XmlReader to read an XML file. I can open

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.