A simple tip which saves a lot of your time...
You can simply convert XML string to an OMElement as below
OMElement resultElement = AXIOMUtil.stringToOM(xmlString);
Extracting values from XML
Sample XML code
Gambardella, Matthew
XML Developer's Guide
Computer
44.95
2000-10-01
An in-depth look at creating applicationswith XML.
Ralls, Kim
Midnight Rain
Fantasy
5.95
2000-12-16
A former architect battles corporate zombies,an evil sorceress.
Corets, Eva
Maeve Ascendant
Fantasy
5.95
2000-11-17
After the collapse of a nanotechnologysociety in England.
Corets, Eva
Oberon's Legacy
Fantasy
5.95
2001-03-10
In post-apocalypse England, the mysteriousagent known only as Oberon.
Java code to retrieve values
OMElement resultElement = AXIOMUtil.stringToOM(xmlString);
Iterator i = resultElement.getChildren();
while (i.hasNext()) {
OMElement book = (OMElement) i.next();
Iterator properties = book.getChildren();
System.out.println("====== book =======");
while (properties.hasNext()) {
OMElement property = (OMElement) properties.next();
String localName = property.getLocalName();
String value = property.getText();
System.out.println(localName + ": " + value);
}
}
Result
====== book =======
author: Gambardella, Matthew
title: XML Developer's Guide
genre: Computer
price: 44.95
publish_date: 2000-10-01
description: An in-depth look at creating applicationswith XML.
====== book =======
author: Ralls, Kim
title: Midnight Rain
genre: Fantasy
price: 5.95
publish_date: 2000-12-16
description: A former architect battles corporate zombies,an evil sorceress.
====== book =======
author: Corets, Eva
title: Maeve Ascendant
genre: Fantasy
price: 5.95
publish_date: 2000-11-17
description: After the collapse of a nanotechnologysociety in England.
====== book =======
author: Corets, Eva
title: Oberon's Legacy
genre: Fantasy
price: 5.95
publish_date: 2001-03-10
description: In post-apocalypse England, the mysteriousagent known only as Oberon.