Originally posted by Gurpreet Saini: I have xml file please tell me the code to get the name of XML file name using SAX parser.
You can't. First of all, the SAX parser doesn't have to be parsing data from a file. Or even from a URL. It could be parsing data from a String variable. And second, the parser doesn't know what it's parsing until you call its parse() method.
How can I get the attributes of xml file using SAX parser without hardcoding them.
When the parser calls your startElement() method, the fourth parameter is a reference to an Attributes object. That's where you get the attributes from. You don't need to hard-code anything.
Joined: Jun 09, 2002
Thank you very much for your response. The thing is I would be getting lets say 10 xml files from client one after the other in the form of String variable. So, I want my SAX parser be so generic that it can parse the incoming String which is nothing but the contents of xml file. So, how do I proceed with parsing ?. Is there way out without hardcoding the elements or tags . How shall I know which String (which xml file in String is coming) ?.