Jump to content
Sign in to follow this  
mircea

Xml help

Recommended Posts

mircea

Hello guys, can you help me with this xml

im using but i just can't understand what is xpath

I 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 />

Share this post


Link to post
Share on other sites
mircea

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

Share this post


Link to post
Share on other sites
mircea

I tried to p.m you but you have it deactivated. Here is the xml file.

Thank you very much for your help

Edited by mircea

Share this post


Link to post
Share on other sites
taietel

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 by taietel

Share this post


Link to post
Share on other sites
mircea

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

Share this post


Link to post
Share on other sites
taietel

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 by taietel

Share this post


Link to post
Share on other sites
mircea

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

Share this post


Link to post
Share on other sites
taietel

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

Share this post


Link to post
Share on other sites
TheCurrent

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?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.