Selecting specific xml tags with SAX parser?

If I were you then I would just use the Simple XML framework to do the XML parsing work for you. It would not be too difficult then to just create a few objects that could tease this data out of the XML.

If I were you then I would just use the Simple XML framework to do the XML parsing work for you. It would not be too difficult then to just create a few objects that could tease this data out of the XML. P.S.I use the Simple project for all my XML so I even wrote a blog post explaining how to use it in Android projects: you can read it here.

To get those two values you would do something like this: public class ExampleHandler extends DefaultHandler { private static final String FORECAST_CONDITION = "forecast_condition"; private boolean day_of_week_dataWanted = false; private boolean high_dataWanted = false; private ParsedExampleDataSet myParsedExampleDataSet = new ParsedExampleDataSet(); public ParsedExampleDataSet getParsedData() { return this. MyParsedExampleDataSet; } public ExampleHandler() { this. MyParsedExampleDataSet = new ParsedExampleDataSet(); } @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if(FORECAST_CONDITION.

Equals(localName)){ if("day_of_week". Equals(localName)){ day_of_week_dataWanted = true; } if("high". Equals(localName)){ high_dataWanted = true; } } } @Override public void characters(char ch, int start, int length) { if(day_of_week_dataWanted){ myParsedExampleDataSet.

SetLowValue(new String(ch, start, length)); day_of_week_dataWanted = false; } if(high_dataWanted){ myParsedExampleDataSet. SetCurrtempValue(new String(ch, start, length)); high_dataWanted = false; } } @Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException { } } But there are more graceful solutions you could look at, hopefully this gives you a hint.

Thanks – Amanni Apr 26 at 21:13 You want to know when your in each XML element and save them all to your 'ParsedExampleDataSet' that way you can use them if you need them later on. Maybe save them into a map. The above gives you what you needed right?

– Blundell Apr 26 at 21:20 No, it didn't return any values. I need to get 4 values for the current day and two for the next day. I am already able to get the values for the current day.

I want to display them immediately they are read – Amanni Apr 26 at 21:30 You should not display them immediately. The XML parser fills your myParsedExampleDataSet object you then call getParsedData() and you can access your variables. – Blundell Apr 26 at 21:36 Yes, that's the way I'm doing it but I still cant get the values in the next day because there are series of tags with the same name – Amanni Apr 26 at 21:40.

I've sorted this by using populating the values in Arrays and when I want to display them I simple use their position in the array to call them.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions