Results 1 to 3 of 3

Thread: Print XML tag

  1. #1
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default Print XML tag

    Hey,

    I have written some java code to Parse an XML file.

    It is almost exactly the same as the code here:

    A Simple Way to Read an XML File in Java - Print Version

    Basically, I have it returning the XML values but what I want to be able to do now is to return the actual tag.

    So if we have:

    <age>22</age>

    I have the code which will return: 22

    Now I need the code to show the actual TAG: <age>

    Does anyone know how this can be done????

    THANKS!!!!!!

  2. #2
    goldhouse is offline Senior Member
    Join Date
    Mar 2007
    Posts
    134
    Rep Power
    0

    Default

    Java Code:
    System.out.println("Age : " + ((Node)textAgeList.item(0)).getNodeValue().trim());
    Assumes this is printing the age Change like this
    Java Code:
    System.out.println("Age : " + ((Node)textAgeList.item(0)).asXMLString().subString(55));
    XMLString() will return an xmlstring just remove the "<?xml version="1.0"?>" so we added the substring function

  3. #3
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Hey,

    Thanks for the quick reply.

    .asXMLString() doesn't seem to be recognized? Any ideas?

Similar Threads

  1. print line
    By kazitula in forum Java Applets
    Replies: 2
    Last Post: 01-26-2008, 02:05 PM
  2. Print Area
    By Riftwalker in forum Advanced Java
    Replies: 0
    Last Post: 11-28-2007, 07:28 PM
  3. doubt about PRINT API
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 09:51 PM
  4. Print A Pdf
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 05:40 AM
  5. print .doc in java
    By Alan in forum Advanced Java
    Replies: 1
    Last Post: 05-17-2007, 04:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •