I'm building an application in which I have to parse XML
attributes. My XML
looks like this:
<ad type="interstitial" animation="none">
<interstitial preload="0" autoclose="0" type="url" url="http://account.mobfox.com/activation_vad.php" orientation="portrait">
</interstitial>
</ad>
I have tried using the following code:
try {
XMLParser parser = new XMLParser();
xml = parser.getXmlFromUrl(URL);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser1 = factory.newPullParser();
parser1.setInput(new StringReader(xml));
while (!"interstitial".equals(parser1.getName())
&& parser1.getEventType() != XmlPullParser.START_TAG) {
parser1.next();
}
Log.d("URL --> ", parser1.getAttributeValue(null, "url"));
} catch (Exception e) {
e.printStackTrace();
}
But, I'm not able to print URL
from the attributes.
What am I doing wrong? Any kind of help will be appreciated.
Try this..
beacuse maybe you are passing parameter in
Log.d
empty or nullEDIT