XMLDOM Question: Code Attached

infonoteinfonote Member Posts: 233
I have solved the problem:
Not perfect, but at least it works. Now will try and add these to a function, and create functions to parse the different data types such as integer, date etc.

XMLNodeList := XMLDOM.getElementsByTagName('Data/Product');
FOR i := 0 TO XMLNodeList.length - 1 DO BEGIN
  XMLNode := XMLNodeList.item(i);
  XMLNodeList2 := XMLNode.selectNodes('Sku');
  FOR j := 0 TO XMLNodeList2.length - 1 DO BEGIN
    XMLNode2 := XMLNodeList2.item(j);
    //TestText := GetReturnValueNode('//Sku',XMLNode2);
    TestText := XMLNode2.text
  END;
END;



Hi,

I am experimenting with XML Dom working on a personal project to read XML data from a webservice.
I am trying to read elements from an XML File.

Attached is the code up till now.

This is the XML I created to experiment with:

Sku: 10000
Sku: 2000

What I am having trouble with is 'looping' the Sku. I am getting the first value of 1000, but I am unable to get the second value.
GetReturnValue is one of the functions I created to eventuallly read the various different data types such as CDATA, Integer, Date, etc.

I must be missing a repeat or a loop somewhere I guess.

XMLDOM.Load(StreamIn);

XMLNodeList := XMLDOM.selectNodes('//Data/Product');
FOR eachNode := 0 TO XMLNodeList.length DO BEGIN
  XMLNode := XMLNodeList.item(eachNode);
  IF NOT ISCLEAR(XMLNode) THEN BEGIN
    TestText := GetReturnValue('//Sku',XMLDOM);
  END;
END;


Thanks in advance
Peter
Sign In or Register to comment.