Contributions
Re: Can't get node values
Thanks T3D, this was my solution: def holder = new com.eviware.soapui.support.XmlHolder( messageExchange.responseContentAsXml ); holder.namespaces.put("ns1", "http://mynamespace" ); // get the count of how many address hints there are def count = holder.getDomNodes("//ns1:GetAddressHintsResponse/ns1:GetAddressHintsResult/ns1:AddressHint").length; // make a new array and populate it with the data we need to check for hint equality AddressHint[] hints = new AddressHint[count]; for (def i = 1; i <= count; i++) { def add = holder.getNodeValue("//ns1:GetAddressHintsResponse[1]/ns1:GetAddressHintsResult[1]/ns1:AddressHint["+i+"]/ns1:AddressLine"); def twn = holder.getNodeValue("//ns1:GetAddressHintsResponse[1]/ns1:GetAddressHintsResult[1]/ns1:AddressHint["+i+"]/ns1:Town"); def pst = holder.getNodeValue("//ns1:GetAddressHintsResponse[1]/ns1:GetAddressHintsResult[1]/ns1:AddressHint["+i+"]/ns1:Postcode"); def sub = holder.getNodeValue("//ns1:GetAddressHintsResponse[1]/ns1:GetAddressHintsResult[1]/ns1:AddressHint["+i+"]/ns1:Suburb"); hints[i-1] = new AddressHint(add, twn, pst, sub); }8 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.1KViews0likes0CommentsCan't get node values
Hi, I need to parse a list of XML objects.I'm having a lot of difficulty actually getting the values out of the XML nodes. Here is sample XML data: <GetAddressHintsResponse> <GetAddressHintsResult> <AddressHint> <Town>Auckland</Town> <AddressLine>Fanshawe Street</AddressLine> <Postcode>1010</Postcode> <StreetType>Street</StreetType> </AddressHint> <AddressHint> <Town>Auckland</Town> <AddressLine>Federal Street</AddressLine> <Postcode>1010</Postcode> <StreetType>Street</StreetType> </AddressHint> </GetAddressHintsResult> </GetAddressHintsResponse> And here's my code: import com.eviware.soapui.support.XmlHolder def holder = new XmlHolder( messageExchange.responseContentAsXml ) holder.namespaces["ns1"] = "http://iag.co.nz/Wizit" def nodes = holder.getDomNodes( "//ns1:GetAddressHintsResponse[1]/ns1:GetAddressHintsResult[1]/ns1:AddressHint" ) for (node in nodes) log.info node.getAttributes().getNamedItem("Town") But all the output is null! Please help me, I have spent hours on this :(8 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.1KViews0likes2Comments