www.webdeveloper.com
Results 1 to 3 of 3

Thread: XML to string

  1. #1
    Join Date
    Jan 2003
    Location
    Thiruvananthapuram, Kerala, India
    Posts
    27

    XML to string

    Hi,

    i got an xml doc of 10 record nodes.

    with the help of a java program i parsed that and queried and retrieved 3 out of 10.
    now i want to convert this 3 node to a string

    i wrote an function which used xsl transformers to convert but it accepts only document, and if i used Document d = node.getParentDocument() it returns the whole xml document and if i use
    Document d = ( Document ) node;
    it throws an exception classcastexception.

    how to convert that xml node to a document so that i can pass it to my function which uses Xsl transformers to convert.

    if there s any other method to do that please help by telling my that
    thanking you

    saju.m

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    If you are using java then there is a obj.toString() method that you can apply at element/node level or another crude way of doing what you want is to create a new document and append the node to it and print it..

    Cheers

    Khalid

  3. #3
    Join Date
    Mar 2003
    Location
    Burlington, Vermont
    Posts
    9
    A Document is not a node in and of itself, which is why the caste fails, you need to call document.documentElement() to get the root node of your document, then you can use that to do what you want (but remember, it will be an element, not a node, so you will have to still caste it to type node).

    Something like:

    (node) d.documentElement();

    should return the root of the doc as a node reference.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles