I have an xml message which i need to parse. However attributeValue is the wrong thing to look for.
this is probably relatively basic but can someone who knows a bit about dom4j tell me how i can get the values for each field/node/element?
Code:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<profileCheckoutRequest \">
<merchantRefNum>12345</merchantRefNum>
<param>
<key>JSESSIONID</key>
<value>12312311231</value>
</param>
<cancelUrl page=\"https://www.example.com/index.php/myaccounts/checkoutRequestFail\">
<param>
<key>JSESSIONID</key>
<value>12312311231</value>
</param>
</cancelUrl>
<paymentMethod>CC</paymentMethod>
<currencyCode>USD</currencyCode>
<shoppingCart>
<description>Potash Shipment</description>
<quantity>3</quantity>
<amount>2500.00</amount>
</shoppingCart>
<ancillaryFees>
<description>PST</description>
<amount>200.00</amount>
</ancillaryFees>
<ancillaryFees>
<description>GST</description>
<amount>100.00</amount>
</ancillaryFees>
<totalAmount>2800.00</totalAmount>
<customerProfile>
<merchantCustomerId>joe.smith@yahoo.com</merchantCustomerId>
<customerTokenId>12312211</customerTokenId>
<isNewCustomer>false</isNewCustomer>
</customerProfile>
</profileCheckoutRequest>
this is the code i have so far...
Code:
Document d = DocumentHelper.parseText(decodedMessage);
Element rootel = d.getRootElement();
Element el = (Element)rootel.selectSingleNode("merchantCustomerId");
fout.write( ("xml is: " + el.attributeValue("merchantCustomerId") + "\n").getBytes() );
Bookmarks