Jump to content
Developer Wiki and Function Reference Links ×

How to query XML ? (second Child of Element)


tom_shady

Recommended Posts

i need to query point data that is stored in an XML - the xml will look similar to

test3.xml

 <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<geo>
<cloud>
	<vector>
		<x>11</x>
		<y>22</y>
	</vector>
	<vector>
		<x>33</x>
		<y>44</y>
	</vector>
</cloud>
</geo> 

this is queried with the following script

PROCEDURE ReadXML;
{Reads data from an XML file, draw a locus}
CONST
kAppFolder = 1;
VAR
hXML		: LONGINT;
xmlFile	: STRING;
result	: INTEGER;
str1,str2: STRING;
BEGIN
UseDefaultFileErrorHandling(FALSE);
hXML:= InitXML;
IF hXML <> 0 THEN BEGIN
	{init xml-libary}
	xmlFile:= 'test3.xml';
	{load file into memory}
	result:= ReadXMLFile(hXML, kAppFolder, xmlFile);
	{ask file}
	result:= GetElementValue(hXML,'/geo/cloud/vector/x',str1);
	result:= GetElementValue(hXML,'/geo/cloud/vector/y',str2);
	{clear memory}
	result:= ReleaseXML(hXML);
	{draw locus}
	Locus(Str2Num(str1),Str2Num(str2));
END ELSE BEGIN
	{error}
	Message('Could not initialize XML reader.');
END;
END;
Run(ReadXML);

i?m using VW 10.5 the functions GetFirstChild(..) GetNextElement(..) are not defined -

HOW can I query the second vector of cloud/ or more generally the second child of an element?

IS there a special path-Syntax?

eg ( not working)

result:= GetElementValue(hXML,'/geo/cloud[2]/x',str2);

?

Link to comment
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...