..... But am not able to fetch the value of LoadTicket" name="description">

I have an XML as below to parse: <LoadTicketRequest> <LoadTicket LoadTicketID="S-123345"> .....
But am not able to fetch the value of LoadTicketId attribute.
My code snippet is as below: DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = db.parse(is); NodeList nodes = doc.getElementsByTagName("LoadTicket"); Element ticketelement = (Element) nodes.item(0); NodeList ticketid = ticketelement.getElementsByTagName("LoadTicketID"); Element eticketid = (Element) ticketid.item(0); System.out.println( "Ticket ID : " + getCharacterDataFromElement(eticketid) );
Can someone help me out as to where am going wrong.

I was able to find the error. I was treating attribute as an element. No more response needed.

Hi Friend,
Please visit the following links:
http://www.roseindia.net/xml/Listingnode.shtml
http://www.roseindia.net/xml/getting-text-values-from-a-nodel.shtml
http://www.roseindia.net/xml/dom/GetData.shtml
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.