mircea Posted April 10, 2011 Share Posted April 10, 2011 Hello guys, can you help me with this xml im using but i just can't understand what is xpathI only want to make it read the Id value and MeasurementData status = Pass Can you help me please ? <?xml version="1.0" encoding="us-ascii" ?> - <OperationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CFT" status="FAIL"> <Flags /> <idType>BSN</idType> <idValue>1057734989</idValue> <prdNumber>PRX-05659-111</prdNumber> <prdRevision>1</prdRevision> <startDate>2011-03-30T15:02:11</startDate> <stopDate>2011-03-30T15:02:53</stopDate> <user>administrator</user> <stationLocationData stageCode="0" hubCode="0" locationCode="0" areaCode="0" computerName="STATION31231" /> <Parameters /> - <Tests> - <TestData name="RECORD_TESTSETNAME" status="PASS"> <Flags /> - <Measurements> - <MeasurementData name="MEASUREMENT" status="PASS" result="NRP-Z22 Ser.100469" lower="" upper="" units=""> <Flags /> </MeasurementData> </Measurements> </TestData> - <TestData name="SW_VERSION" status="PASS"> <Flags /> Link to comment Share on other sites More sharing options...
taietel Posted April 10, 2011 Share Posted April 10, 2011 Hi, mircea. First try to put your xml file in the proper format. I can't figure out where nodes are. taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
mircea Posted April 10, 2011 Author Share Posted April 10, 2011 Any help? I tried in this way to check if it sees the node but still nothing it give's me the following error Incorrect number of parameters in function call.: $nodeArray = _XMLSelectNodes($sXPath) $nodeArray = ^ ERROR The source code #include <_XMLDomWrapper.au3> #include <array.au3> $sXMLFile = "c:\Logs\1057734989-2011-03-30 T03-02-11\1057734989-2011-03-30 T03-02-11.xml" $result = _XMLFileOpen($sXMLFile) If $result = 0 Then MsgBox(0,"", "Error opening " & $sXMLFile) Exit EndIf $sXPath = "OperationData/IdValue" $nodeArray = _XMLSelectNodes($sXPath) if $nodeArray[0] > 0 Then MsgBox(0,"", "Service node found") Else MsgBox(0,"", "Service node NOT found") EndIf Link to comment Share on other sites More sharing options...
mircea Posted April 10, 2011 Author Share Posted April 10, 2011 (edited) I tried to p.m you but you have it deactivated. Here is the xml file. Thank you very much for your help Edited April 10, 2011 by mircea Link to comment Share on other sites More sharing options...
taietel Posted April 10, 2011 Share Posted April 10, 2011 (edited) mircea, try this to get the idValue: #include "_XMLDomWrapper.au3" $sXML ="c:\Logs\1057734989-2011-03-30 T03-02-11\1057734989-2011-03-30 T03-02-11.xml" _XMLFileOpen($sXML) $arVal=_XMLGetValue("idValue") ;it is just under root ConsoleWrite($arVal[1]&@CRLF) edit: typo Edited April 10, 2011 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
mircea Posted April 10, 2011 Author Share Posted April 10, 2011 It give's me this error C:\BSN Reader\test xml.au3 (5) : ==> Incorrect number of parameters in function call.: $arVal=_XMLGetValue("idValue") $arVal=^ ERROR Link to comment Share on other sites More sharing options...
taietel Posted April 10, 2011 Share Posted April 10, 2011 (edited) I've tested it on your xml file and returned the idValue. (UDF version of XMLDomWrapper is 1.0.3.87.). Do you have more than one <idValue> field? If you can not post your xml, make a sample with the same structure and post it here. [edit]typo Edited April 10, 2011 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
mircea Posted April 11, 2011 Author Share Posted April 11, 2011 Taietel thank you for the help, but seems it's more easier for me to make it read a .txt file. Il try to learn better the .xml wrap and maybe i will find out were did i made the mistake in the code. Thank you Link to comment Share on other sites More sharing options...
taietel Posted April 11, 2011 Share Posted April 11, 2011 mircea, you can do some regexp also, for example: $sXML = @ScriptDir&"\1057734989-2011-03-30 T03-02-11.xml" $string = FileRead($sXML) $arVal = StringRegExp($string,"<idValue[^>]*>(.*?)</idValue>",3) for $i = 0 to UBound($arVal) - 1 ConsoleWrite($arVal[$i]&@CRLF) next Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
TheCurrent Posted April 11, 2011 Share Posted April 11, 2011 ins't the error you are getting clear enough. it says incorrect numbers of paramters how many parameter are you passing and how many is the minimum if there's anything like that? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now