We help IT Professionals succeed at work.
Get Started

Delphi & XML: Inserting a node to the in-memory IXMLDOMNodeList

rfwoolf
rfwoolf asked
on
2,290 Views
Last Modified: 2012-05-09
Hi all

Let's say I load an XML file, I then extract some nodes into a IXMLDOMNodeList and now I want to add a node somewhere in the middle of the IXMLDOMNodeList?

Here's an example:

Let's say I have an XML file like this:
<xml>
  <LoopItem file="Casablanca.mpg" />
  <LoopItem file="StarWars.mpg" />
  <LoopItem file="PanicRoom.mpg" />
</xml>

and some code like this:

uses
  msxml;

var
  LoopNodes : IXMLDOMNodeList;

begin
  XML := CoDOMDocument.create;
  xml.async := false; //What the hell does this do?

  XML.Load('C:\MyStupidXMLFile.xml');

  LoopNodes := XML.getElementsByTagName('LoopItem');
end;

This is the pseudocode of what I want to do:
  LoopNodes.InsertNode(2, '<LoopItem file="MinorityReport.mpg" />');
  //Insert into node position 2 the node '<LoopItem file="MinorityReport.mpg" />'
Comment
Watch Question
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE