There are several ways to do this.
You can use, for example, simplexml Framework.
To do this, you can try to create several classes that will help you solve the problem.
UL Class:
import java.util.ArrayList; import java.util.List; import org.simpleframework.xml.ElementList; import org.simpleframework.xml.Root; @Root(name = "ul", strict = false) public class ULTag { @ElementList(name = "li", inline = true, required = false) List<LITag> liTags = new ArrayList<LITag>(); public List<LITag> getLiTags() { return liTags; } public void setLiTags(List<LITag> liTags) { this.liTags = liTags; } public ULTag() { } }
Li class:
import org.simpleframework.xml.Element; import org.simpleframework.xml.Root; @Root(name = "li", strict = false) public class LITag { @Element(name = "strong", required = false) private String strong; public LITag() { } public String getStrong() { return strong; } public void setStrong(String strong) { this.strong = strong; } }
you can also create a strong class if you want to insert more things into it. but here we do not need him.
import org.simpleframework.xml.Element; import org.simpleframework.xml.Root; @Root(name = "strong", strict = false) public class StrongTag { @Element(name = "strong", required = false) private String strong; public StrongTag() { } public String getStrong() { return strong; } public void setStrong(String strong) { this.strong = strong; } }
Removing a deserialization of a simple object
Serializer serializer = new Persister(); File source = new File("yourxmlexampl.xml"); ULTag ulTag = serializer.read(ULTag.class, source);
Do whatever you want with ulTag. eg:
String percent=ulTag.getLITags().get(0).getStrong();
Maybe this can help you. Fill me to write. This is a link about the simplexml structure http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php