1

I have been learning how to build android apps this summer. I am currently trying to work on xml parsing which falls under java in this case. I have a few questions that are mostly conceptual and one specific one.

First, in most of the examples I have seen pages already in xml are used. Can I use a page in regular html format and with whatever the program does turn it to xml and then parse it? Or is that what is normally done anyway?

Secondly, I could use a little explanation on how the parser actually works and saves the data so I will better know how to use it (extract it from whatever it is saved in), when the parsing is done.

So for my specific example I am trying to work with some weather data from the NWS. My program will take the data from this page, and after some user input take you to a page like this, which sometimes will have various alerts. I want to select certain ones. This is what I could use help with. I haven't really coded anything on that yet because I don't know what I am doing.

If I need to clarify or rephrase anything in here I am happy too and let me know. I am trying to be a good contributor on here!

Derek Hodges
  • 15
  • 1
  • 5

1 Answers1

1

Yes you can parse HTML and there are many parsers available too, there is a question about it here Parse HTML in Android, then we have an answer here about parsing html https://stackoverflow.com/a/7114346/826657

Although its a bad idea, as the tag names aren't well named, so you will have to write lots of code searching attributes for a specific data tag, so you always have to prefer XML,for saving lots of code space and also time.

Here is a text from CodingHorror which says at general parsing html is a bad idea. http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html

Here is something which explains parsing an XML document using XML PullParser http://www.ibm.com/developerworks/library/x-android/

Community
  • 1
  • 1
Rachit Mishra
  • 6,101
  • 4
  • 30
  • 51
  • Thank you. I will keep that last reference in mind for xml in the future. For now I may look into something that will allow me to copy the html text and look through it by hand since that is ultimately my goal, even if it's a pain as you said. Hopefully that would be easier than straight parsing of the html – Derek Hodges Aug 31 '13 at 05:06