(Nevermind I already got the solution to this)
I know how to parse an XML file but this is the first time I encountered something with inline values
<?xml version="1.0" encoding="iso-8859-1"?>
<imginfo xmlns="http://ns.xxxxxxxx.com/12/" version="8" timestamp="1406951709">
<files server="540" rownumber="8376">
<image size="177" content-type="image/jpeg">sample_name_here.jpg</image>
</files>
<resolution>
<width>800</width>
<height>486</height>
</resolution>
</imginfo>
How can I extract the value of the server
in this case the value is 540
(using PHP's SimpleXMLElement
)
NodeList nl1= docEle.getElementsByTagName("files");// Accesses the files block
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
Element el = (Element)nl.item(i);
String s=el.getAttribute("server");
}
The getAttribute function is key here for extracting inline values in an xml.