tom_shady Posted January 19, 2007 Share Posted January 19, 2007 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); ? Quote Link to comment
Charles Chandler Posted March 6, 2007 Share Posted March 6, 2007 Try: result:= GetElementValue(hXML,'/geo/cloud/vector[2]/x',str1); result:= GetElementValue(hXML,'/geo/cloud/vector[2]/y',str2); Quote Link to comment
Recommended Posts
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.