<DIV><BR>When I run the below program..I get</DIV>
<DIV> </DIV>
<DIV>org.jdom.input.JDOMParseException: Error on line 1: White space is required between the processing instruction target and data.<BR> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:381)<BR> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:764)<BR> at parseXML.process(parseXML.java:25)<BR> at parseXML.main(parseXML.java:58)<BR>Caused by: org.xml.sax.SAXParseException: White space is required between the processing i<BR>nstruction target and data.<BR> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)<BR> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>import java.io.*;<BR>import java.net.URL;<BR>import java.util.List;<BR>import java.util.Iterator;<BR>import org.jdom.*;<BR>import org.jdom.input.SAXBuilder;<BR>import org.jdom.output.XMLOutputter;</DIV>
<DIV>/**<BR>* This class reads a xml formatted string and parse it<BR>* get a root element, its children and children's attribute.<BR>*/</DIV>
<DIV>public class parseXML <BR>{</DIV>
<DIV> // Download and Process XML File<BR> public void process (String myXMLString)<BR> {<BR> try <BR> {<BR> // Use SAXBuilder<BR> SAXBuilder builder = new SAXBuilder();<BR> Document doc = builder.build(new StringReader(myXMLString));<BR> extractElements(doc);<BR> } <BR> catch (Exception e) <BR> {<BR> e.printStackTrace();<BR> }<BR> }</DIV>
<DIV> // Walk through JDOM Tree and extract all articles<BR> // For each article, print article ID, headline text and source</DIV>
<DIV> private void extractElements(Document doc) <BR> {<BR> Element root = doc.getRootElement();<BR> <BR> List login = root.getChildren("studentLogin");<BR> Iterator i = login.iterator();<BR> System.out.println("Number of nodes "+login.size() );</DIV>
<DIV> while(i.hasNext()){<BR> Element user = (Element)i.next();<BR> </DIV>
<DIV> String userID = root.getChildText("userID");<BR> String password = root.getChildText("password");<BR> }<BR> }</DIV>
<DIV> public static void main (String[] args) <BR> {<BR> System.out.println ("Parsed Values");<BR> parseXML xml = new parseXML();<BR> </DIV>
<DIV>xml.process("<?xmlversion=\"1.0\"encoding=\"UTF-8\"?><studentLogin><userID>hanuman</userID><password>maruti</password></studentLogin>");<BR> }</DIV>
<DIV>}</DIV>
<DIV> </DIV><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://pa.yahoo.com/*http://rd.yahoo.com/evt=1207/*http://promo.yahoo.com/sbc/">SBC Yahoo! DSL</a> - Now only $29.95 per month!