1
我試圖從預設的xml文件中提取值,並且當我嘗試檢查值是什麼時,我總是收到空值。Xmlparser.getText()給出null
if (pulled.equals("preset")) {
presetName = xmlParser.getAttributeValue(null,"name");
Log.d(TAG, presetName + " = " + xmlParser.getText());
}
這是XML IM從
<?xml version="1.0" encoding="utf-8"?>
<sports>
<sport name="Baseball" paid="false">
<preset name="Pitching Mound">726.0</preset>
<preset name="Base Distance">1080.0</preset>
</sport>
<sport name="Basketball" paid="false">
<preset name="NBA Free Throw Line">181.08</preset>
<preset name="NBA 3pt Line">265.8</preset>
</sport>
<sport name="Cricket" paid="true">
<preset name="Cricket Pitch">2012.0</preset>
<preset name="Testing">0.8</preset>
</sport>
</sports>
拉動的價值難道我做錯了什麼?
我之前http://stackoverflow.com/questions/22626450/looping-an-xml-parser-till-a-tag-is-done回答了這個問題,它應該工作 – Raghunandan