Jump to content

Xml help


Recommended Posts

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 />
Link to comment
Share on other sites

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

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...