[android-developers] About XML parising

2010-02-19 Thread CMF
I have my code here

Document dom;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try
{
DocumentBuilder db = dbf.newDocumentBuilder();
dom =
db.parse(strings.xml); //
here I don't know the path of strings.xml which is in the res/values.
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
}

...// which I expect I can get the content needed ...but the keypoint
is , i dont know how to read the res/values/strings.xml as the input
stream.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] About XML parising

2010-02-19 Thread Mark Murphy
CMF wrote:
 I have my code here
 
 Document dom;
 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 try
 {
 DocumentBuilder db = dbf.newDocumentBuilder();
 dom =
 db.parse(strings.xml); //
 here I don't know the path of strings.xml which is in the res/values.
 }catch(ParserConfigurationException pce) {
 pce.printStackTrace();
 }catch(SAXException se) {
 se.printStackTrace();
 }catch(IOException ioe) {
 ioe.printStackTrace();
 }
 
 ...// which I expect I can get the content needed ...but the keypoint
 is , i dont know how to read the res/values/strings.xml as the input
 stream.

You cannot read res/values/strings.xml as XML. If you want XML
resources, put them in res/xml and use the Resources object to get an
XmlPullParser.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 14-18 June 2010: http://bignerdranch.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en