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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:01:45+00:00 2026-05-31T22:01:45+00:00

Using the MSXML2 functions from the msxml3.dll library, I’m trying to duplicate sections in

  • 0

Using the MSXML2 functions from the “msxml3.dll” library, I’m trying to duplicate sections in an XML document, but it does not work as I expected.

Here is the XML:

<result>
     <Target>
          <Point>
            <pos dimension="2">60.384005 5.333862</pos>
          </Point>
      </Target>
</result>

What I want is to add multiple sections. So I want to take the node, duplicate it and put it under the existing <Target> node. I’m almost convinced I should use the Clone method, but it does not seem to work.
The C++ code:

    typedef MSXML2::IXMLDOMNodePtr XmlNode;  

    XmlNode pNode = pXMLRequest->selectSingleNode("//result");
if(pNode==NULL)
    { m_szErrorText =  m_szErrorText + _T(" 'result' node not found");return FALSE;}    

    XmlNode pTargetNode = pNode->selectSingleNode("Target");
    XmlNode pNewTargetNode  = pTargetNode->cloneNode(true);
    pNode->appendChild(pNewTargetNode);

But when I run this code nothing happens to the XML document. And when I inspect the XML text in pNewTargetNode I see it is '<result>' only which is just the name of the node While I would expect it to contain all the nodes in <Target>...</Target>. Is there something I am missing ?

  • 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-05-31T22:01:46+00:00Added an answer on May 31, 2026 at 10:01 pm

    I used the wrong kind of ‘true’.
    If I replace

    XmlNode pNewTargetNode  = pTargetNode->cloneNode(true);
    

    with

    XmlNode pNewTargetNode  = pTargetNode->cloneNode(VARIANT_TRUE);
    

    it works fine. I had already thought about this and used TRUE instead of true, but that does not work either.
    So when using the msxml library alsways use VARIANT_BOOL, VARIANT_FALSE and VARIANT_TRUE.

    Raymond Chen explains why there are so many variations:
    http://blogs.msdn.com/b/oldnewthing/archive/2004/12/22/329884.aspx

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

Sidebar

Related Questions

I'm familiar with using the MSXML2 library for reading xml files. But is there
I am using MSXML3 and have loaded an xml document which is a HTML
I'm using VBA to parse the soap xml with MSXML2 and XPath but while
I'm generating an XML document in VBA using the MSXML2.DOMDocument and then sending the
I'm using Delphi to create an XML document from data in a relational database.
Using MSXML4, I am creating and saving an xml file: MSXML2::IXMLDOMDocument2Ptr m_pXmlDoc; //add some
I am trying to do a simple application using Ajax and servlet. But when
I'm trying to feed data from SQL database to FLEX, using php script in
I need to load xml file from specified url using javascript. Here is what
I have a VBScript COM Component where I'm using Msxml2.FreeThreadedDOMDocument.4.0 however is there /

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.