So I am pretty new to XML parsing, but I looked around and I found some info that was of value to me. I came across something called XPath and I thought that it might work. Unfortunately, I am having some trouble with it.
Currently I am trying to get a string using this line of code:
String summaryFedEx = (String) xpath.evaluate("/SOAP-ENV:Envelope/SOAP-ENV:Body/v4:TrackReply/v4:HighestSeverity", dom, XPathConstants.STRING);
Before you ask, dom
is fine. So that leaves me to believe the expression itself is wrong.
Below I have the XML I am trying to parse. Maybe someone could give some assistance?
I should note: I am trying to get the "v4:HighestSeverity" data.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<v4:TrackReply xmlns:v4="http://fedex.com/ws/track/v4">
<v4:HighestSeverity>ERROR</v4:HighestSeverity>
<v4:Notifications>
<v4:Severity>ERROR</v4:Severity>
<v4:Source>prof</v4:Source>
<v4:Code>1000</v4:Code>
<v4:Message>Authentication Failed</v4:Message>
</v4:Notifications>
<v4:TransactionDetail>
<v4:CustomerTransactionId>TC030_WSVC_Track_v4 _POS</v4:CustomerTransactionId>
<v4:Localization>
<v4:LanguageCode>EN</v4:LanguageCode>
</v4:Localization>
</v4:TransactionDetail>
<v4:Version>
<v4:ServiceId>trck</v4:ServiceId>
<v4:Major>4</v4:Major>
<v4:Intermediate>0</v4:Intermediate>
<v4:Minor>0</v4:Minor>
</v4:Version>
</v4:TrackReply>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>