Access data in XML file using MSXML2.DOMDocument

Posted on 2015-01-26
Last Modified: 2016-02-26
I have a document formatted like this:

<TestResult xmlns:xsi="" xmlns:xsd="">
<Name>Fred Smith</Name>

I'm loading it as follows:

    Set objXMLHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    objXMLHttp.Open "GET", strURL, False
' This works but strReturn is formatted using { and : characters not as xml/soap
    strReturn = objXMLHttp.responseText
    Set xmlDoc = CreateObject("MSXML2.DOMDocument")
    xmlDoc.async = False
    xmlDoc.LoadXML strReturn

xmldoc as a Parse error, invalid at top level of document

How do I access the score and learner id ?
Question by:ASPDaddy
  • 4

Author Comment

ID: 40571340
I solved the parse error by setting the content type to XML, it was defaulting to JSON. The doc now looks loaded ok so I just need to know the syntax to access specif elements in the test and candidate.  The example is a single record but I like to know how to access using a loop as well in case we make files with more records. Thanks
LVL 23

Expert Comment

ID: 40573159

Accepted Solution

ASPDaddy earned 0 total points
ID: 40573176

I had a look at that yesterday , its generic code for traversing a structure rather than specific access to known elements.

I figured it eventually by trial an error though :)

- For top level test data

- for data in the Learner record

Author Comment

ID: 40573179

Author Closing Comment

ID: 40582246
actual code

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question