How to store single result from XPath Extractor - regex

I have a HTTP request that return the following XML
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:obterAtividadesResponse xmlns:NS1="http://www.multiplan.com.br/APL/CLIE/SN/BPM/v1">
<atividades>
<atividade>
<instancia>
<idInstancia>2024</idInstancia>
</instancia>
<idAtividade>12887</idAtividade>
<nomeProcesso>Nota Fiscal ao Pagamento - Resumido</nomeProcesso>
<nomeAtividade>Aprovar Pagamento</nomeAtividade>
<statusAtividade>Received</statusAtividade>
<statusInstancia>Active</statusInstancia>
<dataLimite>2017-09-13T16:08:44.994+00:00</dataLimite>
<snapshot>76</snapshot>
<dadosNegocio>
<name>pedido</name>
<value>4500529987</value>
</dadosNegocio>
</atividade>
</atividades>
</NS1:obterAtividadesResponse>
</soapenv:Body>
</soapenv:Envelope>
I'm trying to extract the idAtividade content with XPath Extractor and save the result on atividadeId variable, but it's saving it's value on atividadeId_1 as you can see in the debug sampler result below:
atividadeId=
atividadeId_1=12887
atividadeId_matchNr=1
I'm using the following xpath query:
//atividades/atividade/idAtividade/text()
Is there a way to make it work as I need it?
Thanks

You should check Return entire XPath fragment instead of text content? checkbox.
It will them take the only text using your expression. See manual.
Also consider using Regular Expression Extractor.

If you have more than one atividade instance in response you can use the following XPath expression to get the first match:
//atividades/atividade[1]/idAtividade/text()
Or alternatively you can select idAtividade node value where nomeAtividade equals to Aprovar Pagamento with something like:
//atividades/atividade[nomeAtividade/text()='Aprovar Pagamento']/idAtividade
However given you have only one atividade instance your expression should work fine, you can test it using "XPath Tester" mode of the View Results Tree listener.
See XPath Tutorial and XPath Language Reference for comprehensive information on XPath syntax, axes, functions, etc.

My mistake, my test had an BeanShell Preprocessor setting the value of atividadeId variable to blank and I didn't know it was being executing after each sampler.

Related

How to pass multiple regexpression extracted values to a single http request?

I am sending First request to server:
POST http://192.168.7.101/r2.web/Planning/Scheduling/TimelinefromR3 -->(A)
I have written Regular Expression extractor((?<=\"Values":")(.*?)(?=\")) to extract Resourcenames like "Ray Gwilliams" and "James Mark" from the response of (A),
Now, I have another request(as mentioned below) to which, I need to pass all the Resource names("Ray Gwilliams" and "James Mark") extracted above.
Please let me know how to achieve this.
http://192.168.7.101/R2.Web/Planning/Scheduling/SchedulesAndGroups
POST data:
[{"ColumnName":"CONTACTNAME","ColumnIId":0,"UdfIId":null,"ConditionIId":0,"OperatorIId":1,"SequenceNo":0,"Values":"Ray Gwilliams
","Lookup":null,"LookupIId":0,"LookupSource":0,"LookupType":0,"MultipleOperatorIIds":null,"MultipleValues":null,"ColumnDataType":null},{"ColumnName":"CONTACTNAME","ColumnIId":0,"UdfIId":null,"ConditionIId":0,"OperatorIId":1,"SequenceNo":0,"Values":"James Mark
","Lookup":null,"LookupIId":0,"LookupSource":0,"LookupType":0,"MultipleOperatorIIds":null,"MultipleValues":null,"ColumnDataType":null}
I have not used the regular expression but if you use the JSON Extractor element and put the extracted value into a variable, you would just add the variable into the 2nd POST request. For example:
POST data:
[{"ColumnName":"CONTACTNAME",
"ColumnIId":0,"UdfIId":null,"ConditionIId":0,
"OperatorIId":1,"SequenceNo":0,
"Values":"${variable1} ","Lookup":null,"LookupIId":0,
"LookupSource":0,"LookupType":0,
"MultipleOperatorIIds":null,"MultipleValues":null,
"ColumnDataType":null}, {"ColumnName":"CONTACTNAME",
"ColumnIId":0,"UdfIId":null,
"ConditionIId":0,"OperatorIId":1,
"SequenceNo":0,
"Values":"${variable2} ","Lookup":null,"LookupIId":0,
"LookupSource":0,"LookupType":0,
"MultipleOperatorIIds":null,
"MultipleValues":null,"ColumnDataType":null}
Tip: To get the value you want extracted, use jmeter's JSON Path Tester in the View Results in Tree listenter element or this helper tool: http://jsonpath.com/

Extract Formula (text) field while referencing an existing saved search using NetSuite WebServices

I am trying to extract NetSuite saved search results using webservices. In the response I am only seeing the normal fields(entered in the Results section) but not the Formula (Text) field.
Below is the image of the saved search results section.
Below is the request sent to NetSuite.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:platform_2014_2.webservices.netsuite.com" xmlns:platformMsgs="urn:messages_2014_2.platform.webservices.netsuite.com" xmlns:platformFaults="urn:faults_2014_2.platform.webservices.netsuite.com">
<soap:Header>
<urn5:preferences xmlns:urn5="urn:messages_2014_2.platform.webservices.netsuite.com">
<urn6:warningAsError xmlns:urn6="urn:messages_2014_2.platform.webservices.netsuite.com">false</urn6:warningAsError>
<urn7:disableMandatoryCustomFieldValidation xmlns:urn7="urn:messages_2014_2.platform.webservices.netsuite.com">false</urn7:disableMandatoryCustomFieldValidation>
<urn7:ignoreReadOnlyFields xmlns:urn7="urn:messages_2014_2.platform.webservices.netsuite.com">false</urn7:ignoreReadOnlyFields>
</urn5:preferences>
<urn8:searchPreferences xmlns:urn8="urn:messages_2014_2.platform.webservices.netsuite.com">
<urn9:bodyFieldsOnly xmlns:urn9="urn:messages_2014_2.platform.webservices.netsuite.com">true</urn9:bodyFieldsOnly>
<urn10:pageSize xmlns:urn10="urn:messages_2014_2.platform.webservices.netsuite.com">1000</urn10:pageSize>
<urn11:returnSearchColumns xmlns:urn11="urn:messages_2014_2.platform.webservices.netsuite.com">true</urn11:returnSearchColumns>
</urn8:searchPreferences>
</soap:Header>
<soap:Body>
<platformMsgs:search xmlns:platformMsgs="urn:messages_2014_2.platform.webservices.netsuite.com" xmlns="urn:messages_2014_2.platform.webservices.netsuite.com">
<platformMsgs:searchRecord xsi:type="ns1:CustomerSearchAdvanced" xmlns:ns1="urn:relationships_2014_2.lists.webservices.netsuite.com" savedSearchId="2469"/>
</platformMsgs:search>
</soap:Body>
The response I am seeing is below.
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<platformMsgs:documentInfo
xmlns:platformMsgs="urn:messages_2014_2.platform.webservices.netsuite.com">
<platformMsgs:nsId>WEBSERVICES_TSTDRV840553_091920161097968934683523704_57aaf0b</platformMsgs:nsId>
</platformMsgs:documentInfo>
</soapenv:Header>
<soapenv:Body>
<searchResponse
xmlns="urn:messages_2014_2.platform.webservices.netsuite.com">
<platformCore:searchResult
xmlns:platformCore="urn:core_2014_2.platform.webservices.netsuite.com">
<platformCore:status isSuccess="true"/>
<platformCore:totalRecords>2</platformCore:totalRecords>
<platformCore:pageSize>1000</platformCore:pageSize>
<platformCore:totalPages>1</platformCore:totalPages>
<platformCore:pageIndex>1</platformCore:pageIndex>
<platformCore:searchId>WEBSERVICES_TSTDRV840553_091920161097968934683523704_57aaf0b</platformCore:searchId>
<platformCore:searchRowList>
<platformCore:searchRow xsi:type="listRel:CustomerSearchRow"
xmlns:listRel="urn:relationships_2014_2.lists.webservices.netsuite.com">
<listRel:basic
xmlns:platformCommon="urn:common_2014_2.platform.webservices.netsuite.com">
<platformCommon:comments>
<platformCore:searchValue>test</platformCore:searchValue>
</platformCommon:comments>
<platformCommon:entityId>
<platformCore:searchValue>test c 97161</platformCore:searchValue>
</platformCommon:entityId>
<platformCommon:entityStatus>
<platformCore:searchValue internalId="13"/>
</platformCommon:entityStatus>
<platformCommon:internalId>
<platformCore:searchValue internalId="59951"/>
</platformCommon:internalId>
</listRel:basic>
</platformCore:searchRow>
<platformCore:searchRow xsi:type="listRel:CustomerSearchRow"
xmlns:listRel="urn:relationships_2014_2.lists.webservices.netsuite.com">
<listRel:basic
xmlns:platformCommon="urn:common_2014_2.platform.webservices.netsuite.com">
<platformCommon:comments>
<platformCore:searchValue>test</platformCore:searchValue>
</platformCommon:comments>
<platformCommon:entityId>
<platformCore:searchValue>test c 97162</platformCore:searchValue>
</platformCommon:entityId>
<platformCommon:entityStatus>
<platformCore:searchValue internalId="13"/>
</platformCommon:entityStatus>
<platformCommon:internalId>
<platformCore:searchValue internalId="59952"/>
</platformCommon:internalId>
</listRel:basic>
</platformCore:searchRow>
</platformCore:searchRowList>
</platformCore:searchResult>
</searchResponse>
</soapenv:Body>
I don't see any explanation/examples related to this in NetSuite help guide as well.
Is there any other way that we need to trigger the request for extracting formula fields? Any pointers would be greatly helpful.
Thanks
I've been looking into this same topic and I don't believe Web Services supports formula fields in the result set. There appears to be no mechanism for returning them in a statically defined SOAP response. In my case, I needed the following formula.
GREATEST({trandate},{lastmodifieddate},{linelastmodifieddate},{billingtransaction.trandate},{billingtransaction.lastmodifieddate},{billingtransaction.linelastmodifieddate})
It existed in my saved search and did not throw an error when referenced from SuiteTalk. However, the formula field was not present as a column in my result set. I had to include each individual field used in my formula in the saved search and then recreate the formula in code.
If you need to use a formula as part of your filter criteria (to apply to a saved search), it will need to be defined in the saved search itself. You will not be able to apply formula based filters via the SuiteTalk API.
TransactionSearchAdvanced customSearch = new TransactionSearchAdvanced()
{
savedSearchScriptId = "customsearch_[Your ID here]"
,
criteria = new TransactionSearch()
{
[Formula fields are NOT supported here]
}
};

Xpath matching expression gives two strings values

I have an requirement to extract below value.
<cidx:ReferenceInformation ReferenceType="DeliveryNoteNumber">
<cidx:DocumentReference>
<cidx:DocumentIdentifier>5004330471</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ReferenceInformation>
I am using the below Xpath expression and getting 2 values match.
Expression
/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ShipNotice']/*[local-name()='ShipNoticeBody']/*[local-name()='ShipNoticeProperties']/*[local-name()='ReferenceInformation']/*[local-name()='DocumentReference']/*[local-name()='DocumentIdentifier']/text()
Output
<?xml version="1.0" encoding="UTF-8"?>
<result>
5004330471
0803692106
</result>
I have tested the Xpath in the online tool
[http://www.xpathtester.com/xpath][1]
Below is INPUT XML
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header/>
<SOAP:Body>
<cidx:ShipNotice xmlns:cidx="urn:cidx:names:specification:ces:schema:all:4:0" Version="4.0">
<cidx:Header>
<cidx:ThisDocumentIdentifier>
<cidx:DocumentIdentifier>0000001113658104</cidx:DocumentIdentifier>
</cidx:ThisDocumentIdentifier>
<cidx:ThisDocumentDateTime>
<cidx:DateTime DateTimeQualifier="On">2015-01-22T20:15:35Z</cidx:DateTime>
</cidx:ThisDocumentDateTime>
<cidx:From>
<cidx:PartnerInformation>
<cidx:PartnerName>MOS Company</cidx:PartnerName>
<cidx:PartnerIdentifier Agency="AGIIS-EBID">1234567890123</cidx:PartnerIdentifier>
<cidx:AddressInformation>
<cidx:AddressLine>N. Lindbergh</cidx:AddressLine>
<cidx:CityName>Columbia</cidx:CityName>
<cidx:StateOrProvince>MO</cidx:StateOrProvince>
<cidx:PostalCode>63190</cidx:PostalCode>
<cidx:PostalCountry>US</cidx:PostalCountry>
</cidx:AddressInformation>
</cidx:PartnerInformation>
</cidx:From>
<cidx:To>
<cidx:PartnerInformation>
<cidx:PartnerName> DIV BOWLNG GR VERA</cidx:PartnerName>
<cidx:PartnerIdentifier Agency="AssignedByPapiNet">0001664057</cidx:PartnerIdentifier>
<cidx:ContactInformation>
<cidx:ContactName>2015</cidx:ContactName>
<cidx:ContactDescription>SeedYear</cidx:ContactDescription>
</cidx:ContactInformation>
<cidx:ContactInformation>
<cidx:ContactName>1024122440000</cidx:ContactName>
<cidx:ContactDescription>AGIIS-EBID</cidx:ContactDescription>
</cidx:ContactInformation>
<cidx:AddressInformation>
<cidx:AddressLine>17410 PIKE 291</cidx:AddressLine>
<cidx:CityName>BOWLING GREEN</cidx:CityName>
<cidx:StateOrProvince>MO</cidx:StateOrProvince>
<cidx:PostalCode>633343045</cidx:PostalCode>
<cidx:PostalCountry>US</cidx:PostalCountry>
</cidx:AddressInformation>
</cidx:PartnerInformation>
</cidx:To>
</cidx:Header>
<cidx:ShipNoticeBody>
<cidx:ShipNoticeProperties>
<cidx:ShipmentIdentification>
<cidx:DocumentReference>
<cidx:DocumentIdentifier>0803692106</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ShipmentIdentification>
<cidx:ShipDate>
<cidx:DateTime DateTimeQualifier="On">2015-01-22T00:00:00Z</cidx:DateTime>
</cidx:ShipDate>
<cidx:PurchaseOrderInformation>
<cidx:DocumentReference>
<cidx:DocumentIdentifier>PO8956234</cidx:DocumentIdentifier>
<cidx:ReferenceItem>000530</cidx:ReferenceItem>
</cidx:DocumentReference>
</cidx:PurchaseOrderInformation>
<cidx:TransportMethodCode Domain="UN-Rec-19">3</cidx:TransportMethodCode>
<cidx:ReferenceInformation ReferenceType="DeliveryNoteNumber">
<cidx:DocumentReference>
<cidx:DocumentIdentifier>5004330471</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ReferenceInformation>
<cidx:ReferenceInformation ReferenceType="BillOfLadingNumber">
<cidx:DocumentReference>
<cidx:DocumentIdentifier>0803692106</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ReferenceInformation>
<cidx:ShipNoticeDate>
<cidx:DateTime DateTimeQualifier="On">2015-01-22T20:15:35Z</cidx:DateTime>
</cidx:ShipNoticeDate>
</cidx:ShipNoticeProperties>
</cidx:ShipNoticeBody>
</cidx:ShipNotice>
</SOAP:Body>
</SOAP:Envelope>
Can anyone please advise how to get only this value?
<cidx:DocumentIdentifier>5004330471</cidx:DocumentIdentifier>
Looks like you need to test the ReferenceType attribute in the cidx:ReferenceInformation element:
/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ShipNotice']/*[local-name()='ShipNoticeBody']/*[local-name()='ShipNoticeProperties']/*[local-name()='ReferenceInformation' and #ReferenceType='DeliveryNoteNumber']/*[local-name()='DocumentReference']/*[local-name()='DocumentIdentifier']
Note: This xpath can be cleaned up a lot if you can declare the namespaces and use prefixes in the path.
You could also clean it up using * for the prefix if you're using XPath 2.0...
/*:Envelope/*:Body/*:ShipNotice/*:ShipNoticeBody/*:ShipNoticeProperties/*:ReferenceInformation[#ReferenceType='DeliveryNoteNumber']/*:DocumentReference/*:DocumentIdentifier

SoapUI (Groovy) - passing a node value from a response to another request if a condition is true

I would appreciate any help with following:
XML Response:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:GetSeatPlanAvailabilityResponse xmlns:ns2="http://stagecoach.com/schemas/engine/common" xmlns:ns3="http://stagecoach.com/schemas/engine/seat">
<ns3:header>
<ns2:version>1.0</ns2:version>
</ns3:header>
<ns3:journeyDetails>
<ns2:journeyId>4769046</ns2:journeyId>
<ns2:origin>
<ns2:cityId>120</ns2:cityId>
<ns2:description>Memphis, TN</ns2:description>
<ns2:stop>MEM</ns2:stop>
</ns2:origin>
<ns2:destination>
<ns2:cityId>320</ns2:cityId>
<ns2:description>Austin, TX</ns2:description>
<ns2:stop>AUS</ns2:stop>
</ns2:destination>
<ns2:departureDate>2014-07-28Z</ns2:departureDate>
<ns2:departureTime>04:00:00Z</ns2:departureTime>
</ns3:journeyDetails>
<ns3:noOfNonReservableSeatsRemaining>70</ns3:noOfNonReservableSeatsRemaining>
<ns3:singleSeats>
<ns2:singleSeat>
<ns2:seatPlanKey>US1</ns2:seatPlanKey>
<ns2:seatId>7ecc7775-6caa-4e17-80d7-6cfa46be507b</ns2:seatId>
<ns2:seatNumber>1</ns2:seatNumber>
<ns2:seatClassCode>FRN</ns2:seatClassCode>
<ns2:seatDeck>UPPER</ns2:seatDeck>
<ns2:availableForSelection>true</ns2:availableForSelection>
</ns2:singleSeat>
<ns2:singleSeat>
<ns2:seatPlanKey>US2</ns2:seatPlanKey>
<ns2:seatId>fe73cc9a-7c4f-4d1f-80e5-6131926af694</ns2:seatId>
<ns2:seatNumber>2</ns2:seatNumber>
<ns2:seatClassCode>FRN</ns2:seatClassCode>
<ns2:seatDeck>UPPER</ns2:seatDeck>
<ns2:availableForSelection>true</ns2:availableForSelection>
</ns2:singleSeat>
<ns2:singleSeat>
<ns2:seatPlanKey>US3</ns2:seatPlanKey>
<ns2:seatId>20121517-d657-438f-bc26-92bb98b20bb5</ns2:seatId>
<ns2:seatNumber>3</ns2:seatNumber>
<ns2:seatClassCode>FRN</ns2:seatClassCode>
<ns2:seatDeck>UPPER</ns2:seatDeck>
<ns2:availableForSelection>true</ns2:availableForSelection>
</ns2:singleSeat>
<ns2:singleSeat>
<ns2:seatPlanKey>US4</ns2:seatPlanKey>
<ns2:seatId>b93be6b7-ebb9-482e-9ec2-3c9d32beab32</ns2:seatId>
<ns2:seatNumber>4</ns2:seatNumber>
<ns2:seatClassCode>FRN</ns2:seatClassCode>
<ns2:seatDeck>UPPER</ns2:seatDeck>
<ns2:availableForSelection>true</ns2:availableForSelection>
</ns2:singleSeat>
</ns3:singleSeats>
<ns3:doubleSeats/>
<ns3:salesClassInformation>
<ns2:seatClassCode>FRN</ns2:seatClassCode>
<ns2:salesClassCode>SFRN</ns2:salesClassCode>
<ns2:salesClassDescription/>
<ns2:price>3.00</ns2:price>
<ns2:maxPassengers>1</ns2:maxPassengers>
</ns3:salesClassInformation>
<ns3:salesClassInformation>
<ns2:seatClassCode>LEG</ns2:seatClassCode>
<ns2:salesClassCode>SLEG</ns2:salesClassCode>
<ns2:salesClassDescription/>
<ns2:price>7.00</ns2:price>
<ns2:maxPassengers>1</ns2:maxPassengers>
</ns3:salesClassInformation>
<ns3:salesClassInformation>
<ns2:seatClassCode>TBL</ns2:seatClassCode>
<ns2:salesClassCode>STBL</ns2:salesClassCode>
<ns2:salesClassDescription/>
<ns2:price>9.00</ns2:price>
<ns2:maxPassengers>1</ns2:maxPassengers>
</ns3:salesClassInformation>
</ns3:GetSeatPlanAvailabilityResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bas="http://stagecoach.com/schemas/engine/basket" xmlns:com="http://stagecoach.com/schemas/engine/common">
<soapenv:Header/>
<soapenv:Body>
<bas:AddSeatToBasketRequest>
<bas:header>
<com:version>1.0</com:version>
<com:retailOperation>US</com:retailOperation>
<com:channel>WEB</com:channel>
</bas:header>
<bas:basketItemId>56227</bas:basketItemId>
<!--1 or more repetitions:-->
<bas:seatSelectionInput>
<com:passengerOrdinal>1</com:passengerOrdinal>
<com:SeatId>7ecc7775-6caa-4e17-80d7-6cfa46be507b</com:SeatId>
</bas:seatSelectionInput>
<bas:seatSelectionInput>
<com:passengerOrdinal>2</com:passengerOrdinal>
<com:SeatId>d653b812-3230-4a31-88e7-a4ad867fb131</com:SeatId>
</bas:seatSelectionInput>
</bas:AddSeatToBasketRequest>
</soapenv:Body>
</soapenv:Envelope>
My requirement is such that I need to pass <ns2:seatId> to another request, first it should look for condition when <ns2:availableForSelection> is TRUE, or else it should skip to 'FALSE' and select `and pass it to request
Could some one please provide groovy script for above logic?
You will need to adjust the below code for your exact needs, as there is still information missing in your question.
// to read a node from your Response
def grUtils = new com.eviware.soapui.support.GroovyUtils(context)
// depending on when / how your are doing this, you will need to provide the exact test step name
def xmlHolder = grUtils.getXmlHolder("${context.currentStep.name}#Response")
def seatIdNode = xmlHolder.getDomNode("//*:singleSeat[availableForSelection='true']/seatId")
// if nothing was found
if(seatIdNode == null) {
testRunner.cancel("seatId was not found!")
return
}
// you can store this in a testcase property
testRunner.testCase.setPropertyValue("seatId", seatId.firstChild.nodeValue)
// and use it in your next Request as '${#TestCase#seatId}'
There is a way to write the seatId directly into the next Request. If you wish to go that route, I have a blog entry that describes how to generate XML requests.
Lastly, all of this could also be done with pure SoapUI test steps, without the use of Groovy. A Conditional GoTo step would check if the XPath above exists, and bypass your next Request if it is not. A Transfer Property step using the same XPath as above would transfer the value of seatId to your next Request.

XmlDocument returned by web service as XmlNode, then XPath doesn't work?

I'm trying to utilise a web service/method which accepts an XmlDocument and returns an XmlDocument. When I add a reference to this web service to my C# application, the proxy code is defined to use XmlNodes instead of XmlDocuments. This seems fairly well recognised behaviour (but confirmation and/or an explanation would be nice - see SO here).
However, if I take the returned XmlNode object and try and do a simple XPath query to "SelectNodes(XPath)", I get no nodes found - but matching nodes do exist.
If, however, I take the OuterXml of the returned XmlNode, and create myself a new XmlDocument from it, my XPath query finds the nodes I expected.
Why is that ? What is it about the returned XmlDocument/XmlNode (or conversion between) that stops the XPath query from working as expected ?
Thanks.
Edit:
The Xml looks like this:
<Results xmlns="">
<Result>
:
<Success>True</Success>
</Result>
<Result>
:
<Success>False</Success>
</Result>
</Results>
...and the XPath looks like this...
Dim xPath As String = "//Result[Success='False']"
If (xmlResults.SelectNodes(xPath).Count > 0) Then
Throw New ApplicationException("Results returned indicate a problem:- " + xmlResults.OuterXml)
End If
One alternative to creating my own XmlDocument would be to use Linq, as per:
Dim results As XDocument = XDocument.Parse(xmlResults.OuterXml)
If (results.Descendants("Success").Count(Function(node) node.Value.ToLower() = "false") > 0) Then
Throw New ApplicationException("Results returned indicate a problem:- " + xmlResults.OuterXml)
End If