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

  • SEARCH
  • Home
  • 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 6837269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:27:26+00:00 2026-05-26T23:27:26+00:00

I have read som xml into an msxml.IXMLDOMDocument object. However, there is a utility

  • 0

I have read som xml into an msxml.IXMLDOMDocument object. However, there is a utility method in an API that I am using, that I would like to call, but it takes an XmlIntf.IXMLNode as an argument.

Is there a simple way to convert an IXMLDOMNode instance from my document to an IXMLNode so I can pass it to the method without having to load the xml into a TXmlDocument object?

For now I have implemented this workaround:

function ConvertNode(const Node: IXMLDOMNode): IXMLNode;
var
  Document: IXMLDocument;
begin
  Document := NewXMLDocument;
  Document.LoadFromXML(Node.xml);
  Result := Document.DocumentElement;
end;
  • 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-26T23:27:27+00:00Added an answer on May 26, 2026 at 11:27 pm

    You can create an instance of IXMLDocument and “attach” it to your IXMLDOMDocument. Here’s a small example:

    program msxmltest;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils, ActiveX,
      msxml, msxmldom,
      xmldom,
      XMLIntf, XMLDoc;
    
    function MSDOMDocumentToDOMDocument(const MSDOMDocument: IXMLDOMDocument): IDOMDocument;
    begin
      Result := TMSDOMDocument.Create(MSDOMDocument) as IDOMDocument;
    end;
    
    function MSDOMNodeToDOMNode(const MSDOMNode: IXMLDOMNode): IDOMNode;
    const
      NodeClasses: array[ELEMENT_NODE..NOTATION_NODE] of TMSDOMNodeClass =
        (TMSDOMElement, TMSDOMAttr, TMSDOMText, TMSDOMCDataSection,
         TMSDOMEntityReference, TMSDOMEntity, TMSDOMProcessingInstruction,
         TMSDOMComment, TMSDOMDocument, TMSDOMDocumentType, TMSDOMDocumentFragment,
         TMSDOMNotation);
    begin
      Result := NodeClasses[MSDOMNode.nodeType].Create(MSDOMNode) as IDOMNode;
    end;
    
    function MSDOMNodeToXMLNode(const MSDOMNode: IXMLDOMNode; var OwnerDocument: IXMLDocument): IXMLNode;
    begin
      Result := nil;
      if not Assigned(MSDOMNode) then
        Exit;
      if not Assigned(OwnerDocument) then
      begin
        OwnerDocument := TXMLDocument.Create(nil);
        OwnerDocument.DOMDocument := MSDOMDocumentToDOMDocument(MSDOMNode.ownerDocument);
      end;
      Result := TXMLNode.Create(MSDOMNodeToDOMNode(MSDOMNode), nil, (OwnerDocument as IXMLDocumentAccess).DocumentObject);
    end;
    
    var
      Indent: Integer = 0;
    
    procedure ShowNode(const Node: IXMLNode);
    var
      I: Integer;
    begin
      Inc(Indent);
      Writeln;
      Writeln(StringOfChar(' ', Indent * 2) + 'NodeName: ' + Node.NodeName);
      Writeln(StringOfChar(' ', Indent * 2) + 'NodeType: ' + NodeTypeNames[Node.NodeType]);
      for I := 0 to Node.AttributeNodes.Count - 1 do
        ShowNode(Node.AttributeNodes[I]);
      if Node.HasChildNodes then
        for I := 0 to Node.ChildNodes.Count - 1 do
          ShowNode(Node.ChildNodes[I])
      else
        Writeln(StringOfChar(' ', Indent * 2) + 'NodeValue: ' + Node.NodeValue);
      Dec(Indent);
    end;
    
    procedure Main;
    var
      MSDOMDocument: IXMLDOMDocument;
      XMLDocument: IXMLDocument;
      MSDOMNode: IXMLDOMNode;
    begin
      MSDOMDocument := CoDOMDocument.Create;
      MSDOMDocument.load('C:\Program Files\Embarcadero\RAD Studio\8.0\ObjRepos\en\Code_Templates\Delphi\blockcomment.xml');
      MSDOMNode := MSDOMDocument.documentElement;
      // show all
      ShowNode(MSDOMNodeToXMLNode(MSDOMNode, XMLDocument)); // you can reuse XMLDocument
      Writeln;
      // show author
      MSDOMNode := MSDOMDocument.selectSingleNode('/codetemplate/template/author');
      ShowNode(MSDOMNodeToXMLNode(MSDOMNode, XMLDocument));
    
      Readln;
    end;
    
    
    begin
      ReportMemoryLeaksOnShutdown := True;
      try
        CoInitialize(nil);
        try
          Main;
        finally
          CoUninitialize;
        end;
      except
        on E: Exception do
        begin
          ExitCode := 1;
          Writeln(Format('[%s] %s', [E.ClassName, E.Message]));
        end;
      end;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read that using database keys in a URL is a bad thing
I have read about how to implement security into a website using hashing, and
I have read every where that primitive datatype and object references are passed by
I have read that errors.add_to_base should be used for errors associated with the object
I have read a lot that LISP can redefine syntax on the fly, presumably
I have read on Stack Overflow some people that have converting to C#2.0 to
I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can
I have read in some of the ClickOnce posts that ClickOnce does not allow
I have read tutorials and several stack overflow posts that suggest I should use
i have read the thread Google Goggles API . and From NotAnotherCodeBlog have created

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.