XML DOM - getting data inbetween tags

Discussion in 'Java' started by Mike Miller, Oct 18, 2003.

  1. Mike Miller

    Mike Miller Guest

    I am using apache's xerces (most recent) and Niko HTML to parse html
    documents in to DOM objects to alter element's attribute values. After
    getting html documents parsed successfully I can extract the node objects
    and change the desired attributes.. My problem is this, how do I return the
    document as a String after I have altered the node elements' attributes? My
    other question is how can I access the data that would be in between tags
    (i.e. <mytag>Text content here</mytag>)?

    I have done some but limited research without much success, but I have
    looked at the API's very closely and either there is something I don't
    understand (which isn't inconceivable) or its not there...

    If anyone could help me out on this, that would be great!

    Thank you,

    Mike Miller
    Mike Miller, Oct 18, 2003
    #1
    1. Advertising

  2. Mike Miller

    Murat G. Guest

    AFAIK, to get the String representation of the document, you need to
    write (or use) a general purpose DOM tree traversing code... I am not
    aware of any interface method...

    Re. data between tags: the text content within a DOM element is just a
    type of node (TEXT_NODE) belonging to the child node list of that
    element... You can use getChildNodes method to get a list of all child
    nodes of an element and then weed out what you need.

    Hope this helps,
    Murat G.

    "Mike Miller" <> wrote in message news:<>...
    > I am using apache's xerces (most recent) and Niko HTML to parse html
    > documents in to DOM objects to alter element's attribute values. After
    > getting html documents parsed successfully I can extract the node objects
    > and change the desired attributes.. My problem is this, how do I return the
    > document as a String after I have altered the node elements' attributes? My
    > other question is how can I access the data that would be in between tags
    > (i.e. <mytag>Text content here</mytag>)?
    >
    > I have done some but limited research without much success, but I have
    > looked at the API's very closely and either there is something I don't
    > understand (which isn't inconceivable) or its not there...
    >
    > If anyone could help me out on this, that would be great!
    >
    > Thank you,
    >
    > Mike Miller
    Murat G., Oct 19, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Girish
    Replies:
    3
    Views:
    402
    Girish
    Feb 24, 2004
  2. Replies:
    0
    Views:
    532
  3. Replies:
    3
    Views:
    511
    Stefan Behnel
    Aug 3, 2007
  4. jason

    difference inbetween macro & function

    jason, Nov 6, 2007, in forum: C Programming
    Replies:
    6
    Views:
    417
    Charlie Gordon
    Nov 8, 2007
  5. Replies:
    54
    Views:
    438
    Michele Dondi
    Jan 16, 2005
Loading...

Share This Page