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 71709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:55:49+00:00 2026-05-10T19:55:49+00:00

I am working on an automated testing app, and am currently in the process

  • 0

I am working on an automated testing app, and am currently in the process of writing a function that compares values between two XML files that should be identical, but may not be. Here is a sample of the XML I’m trying to process:

<?xml version='1.0' encoding='utf-8'?> <report xmlns='http://www.**.com/**'>   <subreport name='RBDReport'>     <record rowNumber='1'>       <field name='Time'>         <value>0</value>       </field>       <field name='Reliability'>         <value>1.000000</value>       </field>       <field name='Unreliability'>         <value>0.000000</value>       </field>       <field name='Availability'>         <value> </value>       </field>       <field name='Unavailability'>         <value> </value>       </field>       <field name='Failure Rate'>         <value>N/A</value>       </field>       <field name='Number of Failures'>         <value> </value>       </field>       <field name='Total Downtime'>         <value> </value>       </field>     </record> 

(Note there may be multiple <subreport> elements and within those, multiple <record> elements.)

What I’d like is to extract the <value> tags of two documents and then compare their values. That part I know how to do. The problem is the extraction itself.

Since I’m stuck in C++, I’m using MSXML, and have written a wrapper to allow my app to abstract away the actual XML manipulation, in case I ever decide to change my data format.

That wrapper, CSimpleXMLParser, loads an XML document and sets its ‘top record’ to the document element of the XML document. (CRecord being an abstract class with CXMLRecord one of its subclasses, and which gives access to child records singularly or by group, and also allowing access to the ‘value’ of the Record (values for child elements or attributes, in the case of CXMLRecord.) A CXMLRecord contains an MSXML::MSXMLDOMNodePtr and a pointer to an instance of a CSimpleXMLParser.) The wrapper also contains utility functions for returning children, which the CXMLRecord uses to return its child records.

In my code, I do the following (trying to return all <subreport> nodes just to see if it works):

CSimpleXMLParser parserReportData; parserReportData.OpenXMLDocument(strPathToXML); bool bGetChildrenSuccess = parserReportData.GetFirstRecord()->GetChildRecords(listpChildren, _T('subreport')); 

This is always returning false. The meat of the implementation of CXMLRecord::GetChildRecords() is basically

MSXML2::IXMLDOMNodeListPtr pListChildren = m_pParser->SelectNodes(strPath, m_pXMLNode);  if (pListChildren->Getlength() == 0) {     return false; }  for (long l = 0; l < pListChildren->Getlength(); ++l) {     listRecords.push_back(new CXMLRecord(pListChildren->Getitem(l), m_pParser)); }  return true; 

And CSimpleXMLParser::SelectNodes() is:

MSXML2::IXMLDOMNodeListPtr CSimpleXMLParser::SelectNodes(LPCTSTR strXPathFilter, MSXML2::IXMLDOMNodePtr pXMLNode) {     return pXMLNode->selectNodes(_bstr_t(strXPathFilter)); } 

When run, the top record is definitely being set to the <report> element properly. I can do all sorts of things with it, like getting its child nodes (through the MSXML interface, not through my wrapper) or its name, etc. I know that my wrapper can work, because I use it elsewhere in the app for parsing an XML configuration file, and that works flawlessly.

I thought maybe I was doing something faulty with the XPath query expression, but every permutation I could think of gives no joy. The MSXML::IXMLDOMNodeListPtr returned by IXMLDOMNodePtr::SelectNodes() is always of length 0 when I try to deal with this XML file.

This is driving me crazy.

  • 1 1 Answer
  • 2 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. 2026-05-10T19:55:50+00:00Added an answer on May 10, 2026 at 7:55 pm

    I’m used to doing this with .NET’s XmlDocument objects, but I think the effect is the same here:

    If the XML document includes a namespace — even an unnamed one — then the Xpath query has to use one as well. So, you’ll have to add the namespace to the XMLDoument which you might as well give a name in the code, and the include the prefix in the XPATH query (it doesn’t matter that the prefixes are different between the xml document and the xpath, as long as the namespaces sort it out)

    SO, while you are using an XPath like /report/subreport/record/field/value, you actually need to first set the namespace of your document:

      pXMLDoc->setProperty(_bstr_t('SelectionNamespaces'),                        _bstr_t('xmlns:r='http://www.**.com/**')); 

    and then selectNodes() using /r:report/r:subreport/r:record/r:field/r:value

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

Sidebar

Related Questions

I had just started working on some automated testing tools, namely test complete, which
My automated script for starting and stopping VMWare Server virtual machines has stopped working.
The only thing I don't have an automated tool for when working with SQL
I recently read Ayende's blog post on automatic registration working with XML Configuration. I
I'm working on a project that will be distributed with GNU autoconf/automake, and I
I'm working for a company that has strict coding style guidelines but no automatic
Working with a SqlCommand in C# I've created a query that contains a IN
I've seen the Testing iPhone app with limited network access ( link ) question,
I am working on a fairly complicated project. We have a c# forms app
I'm running a cron file in Google App Engine. It seems to be working

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.