Traversing the entire nodes of an xml document ?

Hi,
I want to traverse through the entire nodes of an if_ixml_document. which is the best way to do this?
Please find the sample document.
<text>
    <id>
         <guid auto="false">
               432543254543
         </guid>
    </id>
     <title>
         <short_title italics="on">
                <bold language = "german">
                     "Hello"
               </bold>
        </short_title>
     </title>
</text>
In this document, i need to traverse through the nodes <text>, <id>, <guid> , <title>, <short_title>, <bold> etc.
Thanks in advance
Regards,
Ishara

Hi,
there are lots of examples in SDN. Could you try, and revert back in case of specific issue?
There are also examples in SAP library: [SAP Library: Parsing an XML document DOM-based|http://help.sap.com/saphelp_nw70/helpdata/en/86/8280d212d511d5991b00508b6b8b11/frameset.htm ], [SAP Library: Traversing the DOM tree|http://help.sap.com/saphelp_nw70/helpdata/en/86/8280de12d511d5991b00508b6b8b11/frameset.htm ], [SAP Library: Traversing the DOM tree with iterators|http://help.sap.com/saphelp_nw70/helpdata/en/86/8280e112d511d5991b00508b6b8b11/frameset.htm ], ...
And there is demo program: BCCIIXMLT12
Sandra

Similar Messages

  • How to obtain the encoding scheme for an XML document

    How do you go about reading the encoding scheme for an XML document??
    More specifically how do I read the line:
    <?xml version="1.0" encoding="UTF-8"?>
    (Using Win32 C++ XML Parser 2.0.3 as SAX).
    null

    I work mostly with the Java versions of the parser so you'll have to make the translation to C++. As far as I know, you can't use the SAX API to access to the encoding.
    You need to use the DOM along with Oracle's extension to the basic DOM functionality. Oracle's package, oracle.xml.parser.v2 defines a class which implements the Document interface called XMLDocument. This class has a method, getEncoding(), which returns the encoding. You would use the method in getDocument() in the Parser base class inherited by DOMParser to retrive the XMLDocument.
    Jeff

  • How to delete a node in an XML document

    Hi,
    My flex plugin loads an XML document that is passed in from
    the ExternalInterace. I have a List control that displays data from
    this XML document.
    The XML looks like:
    <document>
    <response>
    <objectlist>
    <list type="typeValue">
    <object type="typeValue" name="Name Value" id="GUID
    Value1">
    <params>
    <params>
    </object>
    <!-- more objects in this list -->
    </list>
    </objectlist>
    </response>
    </document>
    I set the list dataProvider to
    xmlDoc.response.objectlist.list.object
    Thing is, I want to remove one of the object nodes before I
    display the data (that is, i dont want one of the nodes in the XML
    document to appear in the list).
    How do I do this? I could not find any way to delete an
    existing node in the XML api.
    -Gaurav

    You can either use the "delete" operator:
    delete xmlDoc.response.objectlist.list.object[5]
    where the object to be deleted might be the fifth down
    (you'll have to play with your xml in debug to get the actual
    values down) or convert to xmlListCollection. The xmlListCollection
    provides easy methods to remove the offending nodes or you may
    provide a filterFunction for the collection which will "hide" the
    node.

  • How do I add (or insert) a node into an XML document with JSTL?

    Dear all,
    I am trying to use JSTL to store some data from a form into XML. However, I have read many articles in JSTL and only found that it can only be, as far as those articles are concerned, used to "read" data from XML files, but not "write" to them.
    Am I missing something in JSTL? Or, if I want to write to an XML file (e.g., insert a new node, or modify a node's data), will I have to write my own bean and then use <c:usebean />?
    Thanks very much in advance.
    Regards,
    Robert

    JSTL is not a programming language in and of itself. It is intended to help you to write scriptlet free JSPs.
    JSP pages (by one school of thought) are intended to function as the "View" in a Model-View-Controller architecture.
    Being a view, JSP pages should be able to look at things - but not touch.
    The standard pattern is to go to a servlet first, which invokes the logic, and then forwards to a JSP for rendering.
    Editing XML by adding new nodes etc etc is thus a function of the java code layer - servlet/action whatever you want to call it.
    Giving you the power to edit XML documents via JSTL (ie on a JSP page) takes away from purity of the MVC design.
    Hence why they don't provide the tags for manipulating XML, and only provide the database tags with a disclaimer that they should only be used for prototypes/trivial apps!
    JSTL is designed to replace scriptlet code on a JSP page.
    It can replace 99% of scriptlet code. The other 1% shouldn't be on the JSP in the first place :-)
    cheers,
    evnafets

  • Creating a node in an XML Document

    Hi!
    i need to insert a new element in an existing xml document. for example,
    <bookinfo>
    <book>
    <bookname>A</bookname>
    <author>B</author>
    </book>
    <book>
    <bookname>C</bookname>
    <author>D</author>
    </book>
    </bookinfo>
    In this document if i want to insert another element using Xpath, say,<publisher> in <book> node, how to insert it.
    I'm using DOM parser for parsing the xml file.
    Any help to solve this issue appreciated.
    Thanks in advance.

    final class Foo {
        private static final String MARKUP =
            "<bookinfo>\n" +
              "<book isbn='1234'>\n" +
              "<bookname>A</bookname>\n" +
              "<author>B</author>\n" +
              "</book>\n" +
              "<book isbn='5678'>\n" +
              "<bookname>C</bookname>\n" +
              "<author>D</author>\n" +
              "</book>\n" +
              "</bookinfo>";
        private Foo() {
            super();
        public static final void main(final String[] args)
            throws XPathExpressionException {
            String isbn = args.length > 0 ? args[0] : "1234";
            String publisher = args.length > 1 ? args[1] : "Sample Publisher";
            Document document = ...  // Initialize somehow
            XPath xpath = XPathFactory.newInstance().newXPath();
            String expression = "//bookinfo/book[@isbn=" + isbn + "]";
            Element book = (Element) xpath.evaluate(expression, document.getDocumentElement(), XPathConstants.NODE);
            if (book == null) {
                throw new RuntimeException("Unable to find ISBN " + isbn);
            Element newPublisher = document.createElement("publisher");
            newPublisher.setAttribute("name", publisher);
            book.appendChild(newPublisher);
    }- Saish

  • How can I use DOM to copy Nodes between different XML Document ?

    Can I copy one Node or Element from one XML Document to another Document by DOM ?
    Because I use the Xerces , but it is not work if I want to copy Node between different Document, or I am doing something wrong. Anyone can help me , I will deeply appreciated !!

    check out the importNode() method of Document.

  • How to get the HTTP response body if the body is a malformed XML document

    Hi,
    I am using HTTP service with resultFormat = "e4x" set. What i
    get in response is a malformed XML document in
    some cases. Usually HTTPService throws a FaultEvent with the
    fault detail set to faultCode:Client.CouldNotDecode
    faultString:'Error #1091' or some other Error #1085 and so.
    My client tries to log these errors on the server by using
    another HTTP service again. But i would like to know
    in the client code during run time what exact XML response
    came in the first HTTP response.
    How do i retrieve this information?
    thanks,
    Sunil

    service capture or charles debug proxy can do the job.
    flex builder 4 is rumored to include a traffic sniffer as
    well, but that's next year.

  • To count the repeated entries in a XML document.

    HOW TO COUNT THE REPEATED  NUMBER OF ENTRIES IN A XML DOCUMENT USING THE SAP REPORT PROGRAM?
      <?xml version="1.0" encoding="utf-16" ?>
    - <ROOT>
    - <SYSTEMDETAILS>
    - <item>
      <SYSDETAILSNAME>CODE</SYSDETAILSNAME>
      <SYSDETAILS>00</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>LICENSE</SYSDETAILSNAME>
      <SYSDETAILS>INITIAL</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>BASIS RELEASE</SYSDETAILSNAME>
      <SYSDETAILS>700</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>SYSTEM NAME</SYSDETAILSNAME>
      <SYSDETAILS>IS3</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>CLIENT</SYSDETAILSNAME>
      <SYSDETAILS>800</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>LOCLANG</SYSDETAILSNAME>
      <SYSDETAILS>English</SYSDETAILS>
      </item>
      </SYSTEMDETAILS>
    - <ACH>
    - <item>
      <NAME>HLA0009999</NAME>
      <TLEVEL>01</TLEVEL>
      <TEXT>SAP</TEXT>
      <TEXT4>Application Components</TEXT4>
      <TEXTLOC>Application Components</TEXTLOC>
      </item>
    <item>
      <NAME>ABA0000311</NAME>
      <TLEVEL>02</TLEVEL>
      <TEXT>AP</TEXT>
      <TEXT4>Application Platform</TEXT4>
      <TEXTLOC>Application Platform</TEXTLOC>
      </item>
    - <item>
      <NAME>KPE0000001</NAME>
      <TLEVEL>03</TLEVEL>
      <TEXT>AP-PPE</TEXT>
      <TEXT4>Integrated Product and Process Engineering</TEXT4>
      <TEXTLOC>Integrated Product and Process Engineering</TEXTLOC>
      </item>
    SAY THE  BOLD PART SHOWS 1 USER ,SO HOW MANY TIMES THE SAME USER APPEARS IN THE DOCUMENT.
    HOW CAN I FIND THAT?

    If the same content of file already thr in the Internal table as 1 STRING/LINE then you can loop the internal table count the entries which one you want like
    Kanagaraja L

  • How to add a new node into existing XML Document

    I have a very simple question. I use XML as input argument for PL/SQL procedure that inserts data into the corresponding table. All I have to do is to add a new tag for Primary Key column and put sequence.NEXTVAL - value into it.
    <ROWSET>
    <ROW>
    -- Add <ID_table_name> value </ID_table_name> ??????
    <FIELD1>data1</FIELD1>
    <FIELD2>data1</FIELD2>
    </ROW>
    </ROWSET>
    I've parsed XML, but I couldn't find the way how to insert the new NODE.
    If you know how to use packages XMLDOM, XMLParser for this purpose, please help me!
    Oracle version 8.1.7

    DOMParser parser=new DOMParser();
    XMLDocument xmlDocument=parser.getdocument();
    Node node=xmlDocument.selectSingleNode("/ROWSET/ROW");
    Element element=xmlDocument.createElement(String tagName)
    node.appendChild(element);

  • What is the correct way to validate xml documents in XDB?

    Hi,
    I'm having a problem validating documents stored in XDB.
    The problem showed up while tracking down a bug whereby
    Oracle appeared to store documents that weren't valid.
    Section 8-6 of the 10g manual has the following:
    "By default, the database checks to ensure that XMLType
    instances are well-formed. ... Because full XML schema
    validation (as specified by the W3C) is an expensive
    operation, when XMLType instances are constructed, stored,
    or retrieved, they are not also fully validated."
    Bugger.
    So I'm not trying to work out how to validate the
    documents we already have stored in the database. I'm
    using the following script to check a particular document:
    ---8<---
    declare
    doc xmltype;
    begin
    select extract(res, '/Resource/Contents/*') into doc from resource_view where any_path = '/home/cosmos/AnnualAllocation-1000000010000090.xml';
    if doc.isSchemaBased() = 1 then
    dbms_output.put_line('Schema based ...');
    dbms_output.put_line('Schema URL:' + doc.getSchemaURL());
    doc.schemaValidate();
    else
    dbms_output.put_line('Not schema based');
    end if;
    end;
    ---8<---
    When I run the script, I get the message 'Not schema based',
    which is confusing the heck out of me.
    Here's the first couple of lines from that xml file:
    ---8<---
    <AnnualAllocation
    xmlns="http://digitalsteps.com/schema/cosmos"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://digitalsteps.com/schema/cosmos http://cosmos.com/schema/cosmos/AnnualAllocation.xsd"
    id="AnnualAllocation-1000000010000090">
    ---8<---
    So, these are the observations I've got so far:
    1. The file is schema-based (schemaLocation is present
    and correct); and
    2. The schema is registed (schema url is present in
    user_xml_schemas; AND document is stored in the default
    table).
    I can see no reason why the script doesn't report the xml
    file are being schema-based.
    Any ideas?
    Marcus

    Ashim,
    Try looking at the program:
    CRM_TEST_ORDER_MAINTAIN
    I think that should help you figure out the parameters.
    Good luck,
    Stephen

  • Help needed in removing the duplicate nodes in an xml file

    Hi Friends,
    I need some help in removing the duplicates from a xml file using the Excel Spreadsheet. The xml Im using does not have any schema.
    Can some one please let me know the steps.
    Thanks a lot.

    Hi,
    I got the answer.
    Go to the developers Tab and click on export.
    Select the column where we want to delete the duplicates and click on Remove Duplicates from Data Tab.
    OR go to Home Tab> Conditional Formatting> High light Cell Rules> Duplicate Values. It will highlight all the duplicate values and then remove them manually.
    Thanks.

  • How to extract the element name of an XML Document

    This is how my xml file looks like:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <nsiData>
    - <instance timestamp="2011-05-25 19:01:00">
    <AECI>47.00</AECI>
    <EEI>-553.00</EEI>
    <EES>-91.00</EES>
    <EKPC>-22.00</EKPC>
    <LGEE>-140.00</LGEE>
    <MHEB>-1376.00</MHEB>
    <MISO>-4725.00</MISO>
    <MOWR>55.00</MOWR>
    <ONT>-872.00</ONT>
    <OVEC>-144.00</OVEC>
    <PJM>-1438.00</PJM>
    <SPA>-55.00</SPA>
    <SPC>20.00</SPC>
    <SWPP>69.00</SWPP>
    <TVA>-69.00</TVA>
    <WAUE>-158.00</WAUE>
    </instance>
    - <instance timestamp="2011-05-25 19:02:00">
    <AECI>47.00</AECI>
    <EEI>-555.00</EEI>
    <EES>-91.00</EES>
    <EKPC>-22.00</EKPC>
    <LGEE>-148.00</LGEE>
    <MHEB>-1375.00</MHEB>
    <MISO>-4709.00</MISO>
    <MOWR>55.00</MOWR>
    <ONT>-871.00</ONT>
    <OVEC>-144.00</OVEC>
    <PJM>-1426.00</PJM>
    <SPA>-55.00</SPA>
    <SPC>20.00</SPC>
    <SWPP>82.00</SWPP>
    <TVA>-69.00</TVA>
    <WAUE>-158.00</WAUE>
    </instance>
    </nsiData>
    I want to extract the element name and the element value from this file. I was trying to do it this way:
    SELECT datetime,
    loc.aeci_value,
    loc.eei_value
    FROM temp_xmltype txml,
    XMLTABLE ('/nsiData' PASSING xmldata) misolmp,
    XMLTABLE ('/nsiData/instance' PASSING misolmp.object_value
    COLUMNS
    datetime VARCHAR2(100) PATH '/instance/@timestamp') misodt,
    XMLTABLE ('/nsiData/instance' PASSING misolmp.object_value
    COLUMNS
    aeci_value VARCHAR2(100) PATH '/instance/AECI',
    eei_value VARCHAR2(100) PATH '/instance/EEI') loc
    WHERE txml.feed_id = 127
    But doing it this way does not get me AECI as a column value. Is there any way to get the element name as a column value.
    I am on 11gR2

    The SQL statement you wrote returns 4 rows and there is only two AECI values in there. The corrected version of what you wrote should really be
    SELECT loc.datetime,
           loc.aeci_value,
           loc.eei_value
      FROM temp_xmltype txml,
           XMLTABLE ('/nsiData/instance' PASSING txml.xmldata
                     COLUMNS
                     datetime   VARCHAR2(100) PATH '@timestamp',
                     aeci_value VARCHAR2(100) PATH 'AECI',
                     eei_value  VARCHAR2(100) PATH 'EEI') loc
    WHERE txml.feed_id = 127;If you know the element name and want it returned as a column name, why not just hard code it in the SQL statement, such as
    SELECT loc.datetime,
           'AECI' as AECI,
           loc.aeci_value,
           'EEI' AS EEI,
           loc.eei_value
      FROM temp_xmltype txml,
           XMLTABLE ('/nsiData/instance' PASSING txml.xmldata
                     COLUMNS
                     datetime   VARCHAR2(100) PATH '@timestamp',
                     aeci_value VARCHAR2(100) PATH 'AECI',
                     eei_value  VARCHAR2(100) PATH 'EEI') loc
    WHERE txml.feed_id = 127;I suspect you are really looking for something like {message:id=9535532}
    Note: See the FAQ (under your sign-in name) for how to use the code tag to format code as shown above.

  • UCCX 8 - Dramatic change in the Create File Document step that is used by the Create XML Document step in order to read an XML file

    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-qformat:yes;
    mso-style-parent:"";
    mso-padding-alt:0in 5.4pt 0in 5.4pt;
    mso-para-margin:0in;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:minor-fareast;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
    For the last 5 years (and in IPCC3.x/4.x,UCCX/5.x/7.x) I've used the same basic subflow to read a XML document that contains holiday dates where the queue should be closed.  I've re-used this script on 20+ client installs and it's always worked.  The structure of the script allows you to pass the path and filename of the XML document as parameters to the subflow. (The document is in the repository)
    I loaded this script in UCCX 8.0.2 recently and it crashed with a Java.IO error.  It looked like it was trying to read the file system directly and not the repository. (In the Linux appliance model this kind of makes sense but why is the step trying to read the file system directly?)
    So I open a TAC case (SR# 615243125) and TAC tells me that the method of using the Create File Document step is not supported anymore and that I should specify the filename directly in the Create XML Document step
    The problem that I see (aside from having to edit all my scripts that use XML files) is that the Create XML Document step is looking for the input to be a type DOCUMENT and not a type STRING.  This seems to imply that I have to hardcode the document in each script that I deploy for a customer.  When it was a string it was easy to construct the full file path from parameters and pass to the subflow.
    Questions to the group
    #1 Am I missing something here?
    #2  Do you assume that you'll be able to load a script that worked fine in UCCX 7 into UCCX 8 and that it should completely function when you're doing everything according to the step reference documentation.
    #3 Cisco didn’t document this in any way that I can find.
    #4 How can you use the Create XML Document step in a fashion that would let you construct the path of the file and the filename previously in the script so you could pass it to a subflow ?  It would seem this functionality has been killed in UCCX 8
    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-qformat:yes;
    mso-style-parent:"";
    mso-padding-alt:0in 5.4pt 0in 5.4pt;
    mso-para-margin:0in;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:minor-fareast;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
    (Background)
    Create File Document Step
    The input filename is a STRING, could be an explicit path and filename in the repository or a variable that represents that path and string
    The output of this step is a DOCUMENT to be used in the Create XML Document step
    The string FILE_FullPathHolidayFiles references  en_us\folderName\documentName.xml
    The document was properly uploaded into the repository only, NOT trying to directly read c:\foo\blah…
    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-qformat:yes;
    mso-style-parent:"";
    mso-padding-alt:0in 5.4pt 0in 5.4pt;
    mso-para-margin:0in;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:minor-fareast;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
    The create XML document input can only be a type DOCUMENT

    #1 Am I missing something here?
    You are mixing two different issues together here.
    The Create File Document step is indeed not needed or supported for creating an XML document. That is why there is a unique step; to trigger XML parsing within the MIVR subsystem.
    Accessing the file system is restricted to a single folder within the VOS model (i.e. 8.0+). This folder is not backed up, replicated, or cleaned up automatically. It was intended to give developers some FS access as a temporary swap location only.
    #2  Do you assume that you'll be able to load a script that
    worked fine in UCCX 7 into UCCX 8 and that it should completely
    function when you're doing everything according to the step reference
    documentation.
    Assume nothing; read the documentation and attend one of the dozens of partner training sessions that CCBU put on advising of the upcoming changes.
    #3 Cisco didn’t document this in any way that I can find.
    You're right, I guess, on the Create File vs. XML Document step. AFAIK Cisco never wrote a notice into the Step Reference Guide explicitly stating that you cannot use the Create File Document although the documentation seemed pretty clear to me without it. File system restrictions are documented in the 8.0 release notes.
    Scripting and Development Series: Volume 2, Editor Step ReferenceUse the Create XML Document step to create a logical document that maps a document to another document variable (where the document has already been pre-parsed as an XML document and is ready to be accessed by the Get XML Document Data step).Use this step before the Get XML Document Data step to obtain data from a document formatted using the Extensible Markup Language (XML).
    #4 How can you use the Create XML Document step in a fashion that would
    let you construct the path of the file and the filename previously in
    the script so you could pass it to a subflow ?  It would seem this functionality has been killed in UCCX 8
    No it hasn't; just concatinate a string to build the Source Document parameter the step needs. Example:  "DOC[" + myFilePath + "]"

  • Displaying the entire text of a tree node when the tree isn�t wide enough

    Hi,
    I have a JTree displayed in a JScrollPane, so there is a chance that some of the tree data may be hidden if the tree's width is insufficient, so when the user moves the cursor over a tree node whose text is not completely visible (cut off by the right edge of the scroll pane and/or window), a tooltip is displayed to show the entire node text. So far so good!
    If the user double click a node in the tree a new window is supposed to be opened. This works fine if the tooltip hasn�t been displayed jet, but if it has then the user has to click 3 times to open the window.
    The first time to remove the tooltip and the next 2 opens the window.
    How can I awoid this?
    Thanks!!!!
    :-)Lisa

    Any ideas, please?

  • How to extract the actual XML document from soap message?

    My problem is " how to extract the actual XML document from soap message? "
    i just want to extract the attachment i.e. (pure XML document without any soap header or envolope).
    i could be ver thank full if u could solve my problem.
    [email protected]

    Hi,
    This is some skeleton code for extracting an attachment from a SOAPMessage.
    import javax.activation.DataHandler.;
    import javax.xml.soap.*;
    import javax.xml.message.*;
    Iterator allAttachments = message.getAttachments();
    AttachmentPart ap1 = null;
    while(allAttachments.hasNext()){
    ap1 = (AttachmentPart)allAttachments.next();
    //Check that the attachment is correct one. By looking at its mime headers
    //Convert the attachment part into its DOM representation:
    if(ap1.getContentType() == "text/xml"){
    //Use the activation dataHandler class to extract the content, then create a StreamSource from
    //the content.
    DataHandler attachmentContent = ap1.getDataHandler();
    StreamSource attachmentStream = new StreamSource(attachmentContent.getInputStream());
    DOMResult domAttachment = getDOMResult(attachmentStream);
    domAttachment holds an xml representation of the attachment.
    Hope this helps.

Maybe you are looking for