I have been trying a lot of different tutorials to try read a simple username and password from an xml. Its for an assignment.
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<UserDetails>
<Username User="Bryan" Pass="Boo" />
</UserDetails>
My Connection codes I have been using
public void UserCheck() throws FileNotFoundException, IOException{
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
//file ref
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),"/UserDetails.xml");
//inputstream
FileInputStream fis = new FileInputStream(file.getPath());
//set the input
xpp.setInput(new InputStreamReader(fis));
//Tutorial didnt use the eventType
int eventType = xpp.getEventType();
String nodeName = xpp.getName();
if (nodeName=="Username"){
}
} catch (XmlPullParserException ex) {
Logger.getLogger(Comp4Task2.class.getName()).log(Level.SEVERE, null, ex);
}
The main issue I see is the xpp.getName returns null all the time. I am not sure what I am doing wrong. Thanks for taking a look. I have tried looking it up.. here is what I have tried how to parse xml file from Sdcard in Android Read/write to external XML file in Android