Astronavigator
Astronavigator

Reputation: 2051

MSXML: How can i modify nodes returned by SelectNodes method

Is it possible to modify XML and/or Text of nodes returned by SelectNodes method ?

When i am using SelectSingleNode method i always can modify XML and Text property of returned node:

vXML := CreateOleObject('MSXML2.DOMDocument.6.0')
vXML.Load('...');
vDoc :=  vXML.DocumentElement;
vNode := vDoc.SelectSingleNode(XPath);
vNode.XML := 'My value'; // Works here

But when i am trying to change nodes returned by SelectNodes method i'v got "Invalid number of parameters" OLE-Exception

vValue := vDoc.SelectNodes(XPath);
if vValue.Length>0 then
begin
  N := vValue.Length;
  for I := 0 to N-1 do
    vValue.Item(I).XML := ''; // Exception here
end;

Is it possible to change XML of nodes returned by SelectNode method ?

Upvotes: 3

Views: 1701

Answers (1)

Doc Brown
Doc Brown

Reputation: 20044

Try vValue.Item(I).Text := '' (only for XMLDOMElement type of nodes). And you should tag your question with the programming language you are using, looks like Pascal. Is this Delphi?

Upvotes: 3

Related Questions