Android - Parsing Custom XML File Format into string

gently

New Member
I have an xml file with a custom format which I am trying to store in a string. I am still a beginner with java and have search the forums, but the xml questions asked already appear to relate to xml formats in standard xml format.The xml format I have to work with is as follows:\[code\]<playList baseUrl= "Webaddress"<file name="xxxxxxx.xxx" showTime="YYYY-MM-DD HH:MM" /><file name="xxxxxxx.xxx" showTime="YYYY-MM-DD HH:MM" />.......</playList>\[/code\]I've been trying the sample code for XML parsing, but this is set for particular. I've been trying for hours to overcome this, but I'm stuck even trying to pull in the string into my code.I have been looking at the tutorial here http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/ but I'm still stuck importing the xml file. I believe it is with the hashmap code as my xml format doesn't match the standard tags <> <>.Here is the code I have at present:\[code\]static final String KEY_ITEM ="playlist";static final String KEY_NAME = "name";static final String KEY_DESC = "showTime"; XMLParser parser = new XMLParser(); String xml = parser.getXmlFromUrl(URL); // getting XML Document doc = parser.getDomElement(xml); // getting DOM element NodeList nl = doc.getElementsByTagName(KEY_ITEM); // looping through all item nodes <item> for (int i = 0; i < nl.getLength(); i++) { // creating new HashMap HashMap<String, String> map = new HashMap<String, String>(); Element e = (Element) nl.item(i); map.put(KEY_COST, getString(e)) // adding each child node to HashMap key => value map.put(KEY_NAME, parser.getValue(e, KEY_NAME)); map.put(KEY_DESC, parser.getValue(e, KEY_DESC)); // adding HashList to ArrayList menuItems.add(map);\[/code\]Any help or assistance would be greatly appreciated. Thanks,
 
Back
Top