Removing header node in xml file

Hi Experts,
Actually i want to remove the parentnode tag from the resultant output, do we have any java code to remove such xml nodes.
mt_receiver
HeaderNode
--Field1
--Field2
ParentNode
PurchaseOrder
--Field1
--Field2
PurchaseHeader
--Field1
--Field2
Details
--Field1
--Field2
--Field3
ParentNode
PurchaseOrder
--Field1
--Field2
PurchaseHeader
--Field1
--Field2
Details
--Field1
--Field2
--Field3
regards,
sai

Hi,
Actually i have to process multiple purchase orders which is coming from IDOC and when i didn't use the parent node i am getting all the purchase orders and then purchase order header followed with details,
But i need the detials records and purchase order header corresponding to the purchase order, so for that i have define parent node, but at the output i dont require this parent node..
i mean the output shuld look like below by removing parent node.
mt_receiver
HeaderNode
--Field1
--Field2
PurchaseOrder
--Field1
--Field2
PurchaseHeader
--Field1
--Field2
Details
--Field1
--Field2
--Field3
PurchaseOrder
--Field1
--Field2
PurchaseHeader
--Field1
--Field2
Details
--Field1
--Field2
--Field3
i think you understand now..
regards,
sai

Similar Messages

  • How to delete a perticular node from xml file using java code

    Hii All,
    Now i am trying to delete a perticular node from xml file.Like...
    XML file:
    <Licence>
    <SERVER>
    <was id="1">1</was>
    <was id="2">2</was>
    </SERVER>
    </LICENCE>
    I am working in messaging service using JABBER framework with whiteboard facility.
    Here Some commands i have created to add,modify,delete nodes from xml file.They Are
    1.If u want to add a new node then.
    create Licence.SERVER <ss id="3">ddd</ss> lic.xml
    (here u want to add a new node called "ss" under Licence.SERVER.
    And lic.xml is tyhe xml file name where it was saved.
    2.If u want to delete a node(Suppose <was id="1">),then the command should be
    delete Licence.SERVER.was:id='"1" lic.xml
    A problem arises that here it find two was attributes.And it delete the last was attribute,not the requested node.
    PLEASE HELP ME IN SOLVING THIS CODE..
    ------------------------------------

    Looks like you clicked on "Post" before you pasted in the code you were talking about.

  • Removing Incorrect data from .xml files

    How do I remove info in the .xml files.
    When I 1st got my kit it read my fastest km as 4.55mins/km
    This is way too fast as my average is 6.00mins/km.
    Because the info is incorrect I am not getting congratulated by Paula or being able to improve slowly as I will never get to 4.55.
    HELP

    Haplogroup k,
    I think you have understood me. The file was created
    when the unit wasn't callibrated and recorded a false
    reading which was way too fast for me and a lot of
    runners also.
    I want to post best results now that the machine
    works right.
    Most people have said that they were amazed by how accurate the Nike+ was right from the box without calibration. But I'll take your word for it.
    I can get to the .xml files but it won't delete
    records, that's all I want to do.
    I don't know what you mean by "it won't delete records." Are you talking about your Personal Bests? No you cannot edit that fle. But you can delete a run from your Nano.
    However, you can save all your run data to your computer hard-drive, then RESTORE your Nano. But that will also wipe your calibration data and everything else (personal bests). I guess you could then recalibrate before doing any runs. Then put your old run data (your old xml files) back in your "latest" folder.

  • How to remove empty lines from xml files after removing nodes from document

    <pre>
    Hi
    <b>i have xml document, which is shown below
    after removing some nodes from the document ,i am getting empty lines in place of removed nodes,how to resolve this and get the proper xml document without any errors</b>
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE Message SYSTEM "TRD01.dtd">
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>N</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    <MessageType>T</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>EXM</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>TR</SenderSystemId>
    </Header>
    </Message>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>NIHK</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    the xml output i am getting is
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <MessageType>TRD01</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>STL</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>T</SenderSystemId>
    </Header>
    </Message>
    <b>could you please let me know how to avoid empty lines in the xml doucment output</b>
    this is the method i am using to get the result
    public void ValidateRecord(String xml){
    try{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = factory.newDocumentBuilder();
    //parse file into DOM
    /*DOMParser parser = new DOMParser();
    parser.setErrorStream(System.err);
    parser.setValidationMode(DTD_validation);
    parser.showWarnings(true);*/
    System.out.println ("HI THIS xml is validation "+xml);
    Resolver res = new Resolver();
    db.setEntityResolver(res);
    Document doc = db.parse(new InputSource(new StringReader(xml)));
    XPathFactory xpf = XPathFactory.newInstance();
    XPath xpath = xpf.newXPath();
    // XPathExpression expression = xpath.compile("//A/B[C/E/text()=13]");
    String xmlpath="/Message/Header/CounterPartyType/text()";
    String xmlpath1="/Message/Header/RecipentSystemId/text()";
    String xmlpath2="/Message/Header/ErrorSystemId/text()";
    XPathExpression expression = xpath.compile(xmlpath);
    XPathExpression expression1 = xpath.compile(xmlpath2);
    Object result = expression.evaluate(doc, XPathConstants.NODE);
    Object result1 = expression1.evaluate(doc, XPathConstants.NODE);
    Node node = (Node) result;
    Node node1 = (Node) result1;
    System.out.println("the values of the string is " +node.getNodeValue());
    System.out.println("the values of the string is " +node1.getNodeValue());
    // for (int i = 0; i < nodes.getLength(); i++) {
    //System.out.println(nodes.item(i).getNodeValue());
    // CAHNGING THE RECEIPENT NODE
    XPathExpression expression2 = xpath.compile(xmlpath1);
    Object result2 = expression2.evaluate(doc, XPathConstants.NODE);
    Node node2 = (Node) result2;
    System.out.println(node2);
    node2.setNodeValue(node1.getNodeValue());
    System.out.println(node2);
    //removing the nodes from document
    String xmlpath3="/Message/Header/ErrorCode";
    String xmlpath4="/Message/Header/ErrorEnterPriseId";
    String xmlpath5="/Message/Header/ErrorStatus";
    String xmlpath6="/Message/Header/ErrorSystemId";
    String xmlpath7="/Message/Header/ErrorTimes";
    XPathExpression expression3 = xpath.compile(xmlpath3);
    Object result3 = expression3.evaluate(doc, XPathConstants.NODE);
    Node node3 = (Node) result3;
    node3.getParentNode().removeChild(node3);
    XPathExpression expression4 = xpath.compile(xmlpath4);
    Object result4 = expression4.evaluate(doc, XPathConstants.NODE);
    Node node4 = (Node) result4;
    System.out.println("node value");
    System.out.println(node4.getParentNode().getNodeName());
    node4.getParentNode().removeChild(node4);
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    // Node b13Node = (Node) expression.evaluate(doc, XPathConstants.NODE);
    //b13Node.getParentNode().removeChild(b13Node);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    t.transform(new DOMSource(doc), new StreamResult(System.out));
    catch (Exception e) {
         e.printStackTrace();
    System.out.println(e.getMessage());
    </pre>
    Edited by: user12185243 on Apr 6, 2013 6:38 AM
    Edited by: user12185243 on Apr 6, 2013 6:41 AM
    Edited by: user12185243 on Apr 6, 2013 6:43 AM
    Edited by: user12185243 on Apr 6, 2013 6:45 AM
    Edited by: user12185243 on Apr 6, 2013 9:00 AM

    either this way we can do this
    1)
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    <b> factory.setIgnoringElementContentWhitespace(true); </b>
    DocumentBuilder db = factory.newDocumentBuilder();
    or
    2)
    java.io.StringWriter sw = new java.io.StringWriter();
    StreamResult sr = new StreamResult(sw);
    t.transform(new DOMSource(doc), sr);
    String xml1 = sw.toString().trim();
    <b> xml1=xml1.replaceAll("\\s",""); </b>
    System.out.println(xml1.trim());

  • Remove Header Node in File Content Conversion

    Hi Guys,
         In our scenario receiver payload is
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:MarketInventoryResponse  xmlns:ns1="PRINCIPALS/MarketInventory">
         <Header>
                <CurrentDate>200809</CurrentDate>
         </Header>
         <MarketInventory>
                <Local_ProductCode>121</Local_ProductCode>
                <WH_QTY>20</WH_QTY>
                <WH_Cost>3000</WH_Cost>
                <Store_QTY>40</Store_QTY>
                <Store_Cost>5000</Store_Cost>
          </MarketInventory>
    </ns1:MarketInventoryResponse>
    We are using File content conversion method. Now we got the output is
    200809
    121#20#3000#40#5000
    But We need below mentioned format.
    121#20#3000#40#5000
    we don't need CurrentDate which is in Header node. So, how to ignore Header node in FCC method. Please any one help me.
    Note :  Now we using following parameters in FCC
    Recordset Structure  : MarketInventory
    MarketInventory.addHeaderLine   :  0
    MarketInventory.fieldSeparator     :  #
    MarketInventory.endSeparator      :  'nl'
    Thanks & Regards
    Vijay

    Hi Vijaya,
    You have two options:
    1.-  Sãnthosh Kûmãr V   Solution:
    Recordset Structure : Header,MarketInventory
    Header.fieldFixedLengths = 0
    Header.fixedLengthTooShortHandling = Cut
    Header.endSeparator = '0'
    2.- Use Adapter-Specific Message Attributes in your File adapter.
    In the last one you would have to set the name of your file in FileName atributte.
    Carlos

  • How to remove element namespaces in XML file using DOM or SAX?

    Hi Guys,
    I developed a JAVA mapping in XI to add name spaces for XML file, after mapping,name spaces xmlns="http://www.mro.com/mx/integration" and xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" were added correctly, but for some nodes, such as <Header> and <Content>, a name space xmlns="" was added automatically.Please check below files to compare.
    It looks like be added automatically by XI. I didn't process anything for these nodes in JAVA program.
    Now the issue is, how can I remove these redundant namespaces? Such as xmlns="".
    Can I remove them using DOM or SAX in JAVA Mapping?
    Thanks in advance.
    ====>Original XML file
    <?xml version="1.0" encoding="UTF-8"?>
    <LLYLPPInterface language="EN">
       <Header>
          <SenderID>GBIP</SenderID>
          <CreationDateTime>2008-02-13T22:49:34-05:00</CreationDateTime>
          <RecipientID/>
          <MessageID/>
       </Header>
       <Content>
          <LLY-LPP>
             <INVOICE>
                <INVOICELINE>
                   <PONUM>4780000008</PONUM>
                   <POLINENUM>1</POLINENUM>
                   <INVOICEQTY>1</INVOICEQTY>
                   <LOADEDCOST>68</LOADEDCOST>
                </INVOICELINE>
             </INVOICE>
          </LLY-LPP>
       </Content>
    </LLYLPPInterface>
    ===>Target XML file after JAVA mapping
    <?xml version="1.0" encoding="utf-8"?>
    <LLYLPPInterface language="EN" xmlns="http://www.mro.com/mx/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <Header xmlns="">
              <SenderID>GBIP</SenderID>
              <CreationDateTime>2008-02-13T23:11:55-05:00</CreationDateTime>
              <RecipientID/>
              <MessageID/>
         </Header>
         <Content xmlns="">
              <LLY-LPP>
                   <INVOICE>
                        <INVOICELINE>
                             <PONUM>4780000008</PONUM>
                             <POLINENUM>0</POLINENUM>
                             <INVOICEQTY>1</INVOICEQTY>
                             <LOADEDCOST>68</LOADEDCOST>
                        </INVOICELINE>
                   </INVOICE>
              </LLY-LPP>
         </Content>
    </LLYLPPInterface>
    Edited by: Eddie Zhang on Feb 14, 2008 9:22 AM
    Edited by: Eddie Zhang on Feb 14, 2008 9:24 AM

    Hi Milan,
    Thanks for your replay.
    Actually when I used module XMLAnonymizerBean to convert namespaces, the header of XML, such as <?xml version="1.0" encoding="UTF-8"?> was converted to format <?xml version='1.0' encoding='UTF-8'?>, quote was converted to single quote. Although I set parameter anonymizer.quote = ", it still didn't work, single quote appeared instead of quote.
    I'm not sure why this happened. Can anyone help to clarify this?
    Thanks
    Edited by: Eddie Zhang on Feb 15, 2008 2:11 AM

  • Using Java, How can I Update, Add, Delete nodes in XML Files.

    Hi,
    I want to store the student record (like Name, Age, school name, total mark etc.,) as nodes in the XMLfile. Also I should able to Update, Add, Delete any nodes (student record) in the XML file. How can I achieve this...using Java
    I am able to read the content of the xml file using xml-parser. But my problem is
    updating the xml file.
    pls suggest some solutions or links with " example source code"
    Thanks :-)

    There are 2 kinds of XML parsers : SAX and DOM. DOM seems to suit your need. You can use JAXP APIs to add, delete or change nodes or attributes.
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/TOC.html provides contents that would satisfy most of the needs.
    To save a DOM modified XML file use java IO APIs to write to the same file from which it was read using a Document object ( doc.getNodeValue() ).

  • How do i remove header from a txt file

    Hello. I have an aquisition file and this remove_headers.vi does not remove all my header. I m attaching the file, the remove_header.vi and the file after removeing header.
    Pls help.
    Thanks a lot... 
    Solved!
    Go to Solution.
    Attachments:
    file.txt ‏223 KB
    remove_headers.vi ‏40 KB
    file_after1.jpg ‏231 KB

    Here you go. You should read as string to get the whole header, then delete the first six rows of the array(as previously mentioned). Finally write it back to a new file.
    Regards,
    Even
    Certified LabVIEW Associate Developer
    Automated Test Developer
    Topro AS
    Norway
    Attachments:
    remove_headers_mod.vi ‏12 KB

  • Retrieve / Search specific Node from XML File

    Hello,
    i have a question about reading (searching) XML File within PL SQL:
    There is a XML file with following structure:
    <root>
      <Hnode1 attr1="value1" />
      <Hnode2 attr1="value1" />
         <node1_of_Hnode2 id="10" personname="Steven"/>
         <node2_of_Hnode2 id="20" personname="Christian"/>
         <node3_of_Hnode2 id="30" personname="Arnold"/>
      <Hnode2/>
    <root/>How it is possible to filter a node by one of its attribute value. For example:
    I know the id of a person - lets say id =20. In this case i would like to get the whole node (in this case node2_of_Hnode2) to get the personname => "Christian".
    Just like a SELECT statement (WHERE ID = 20)
    Is there a possibility the get this by one command or should it be looped over all Rows of the Document?. Can you please provide an example for me.
    Thank you in advice!

    Database version is 10.Sorry, that's not a version.
    For example :
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE     10.2.0.5.0     Production
    TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    How to use the extraction of values?
    1.Better in Select statement; assigning directli in a variable or using xmlquery function?.PL/SQL or SQL calls to XMLType methods such as extract() or getStringVal() should be equivalent (putting aside the context switch).
    However, none of them is the correct way to retrieve a scalar value from a given node.
    You must use extractValue() function instead (SQL only) for release < 11.2 and XMLCast/XMLQuery starting with 11.2.
    One more Question:
    I have seen a lot of options to handle with XML Files.
    So in my case only querying data in XML Files is relevant.
    I have seen many APIs called XMLDOM, DMBS_XMLDOM, XMLTYPE...
    When to use these APIS. Can you give me some input on that please?That's a broad topic.
    A relevant answer will depend on your requirement.
    - Do you have to process large files, and if so how large?
    - Is performance/memory management a concern for you?
    - Do you want to extract single values, or process the XML content as relational data?
    If you have any specific test case to show us, please post in the {forum:id=34} forum, and make sure you include all the necessary details (see the FAQ).
    Edited by: odie_63 on 23 févr. 2012 11:35

  • Cannot parse node in XML file

    I have the following xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <model:test xmlns:model="bla">
      <Bounds>
        <Left>0.0</Left>
        <Top>0.0</Top>
        <Width>0.0</Width>
        <Height>0.0</Height>
      </Bounds>
    </model:test>Now I try to parse this using the below code:
        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        domFactory.setNamespaceAware(true);
        DocumentBuilder builder = null;
        try {
          builder = domFactory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
          e.printStackTrace();
        try {
          doc = builder.parse(new File(pathToData));
        } catch (SAXException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        NodeList nodes = doc.getElementsByTagNameNS("model","test");
        Node node = nodes.item(0);
        if(node == null) {
          System.out.println("is null");
        System.out.println(nodes.getLength());  But the null test evaluates to true and it prints:
    is null
    I don't get any exceptions and also specify:
    domFactory.setNamespaceAware(true);
    so why is the node null?

    The problem is here:
    NodeList nodes = doc.getElementsByTagNameNS("model","test");"model" has absolutely no meaning in the DOM, it's simply a short name for the full URI of the namespace you use ("bla" in your example). You need to use this instead:
        NodeList nodes = doc.getElementsByTagNameNS("bla","test");To demonstrate the fact, the following XML would be effectively equivalent to the one you posted
    <?xml version="1.0" encoding="UTF-8"?>
    <foobar:test xmlns:foobar="bla">
      <Bounds>
        <Left>0.0</Left>
        <Top>0.0</Top>
        <Width>0.0</Width>
        <Height>0.0</Height>
      </Bounds>
    </foobar:test>

  • Using live HTTP header get This XML file does not appear to have any style information associated with it. The document tree is shown below

    Im using ReloadEvery 3.6.3 & Live HTTP Headers 0.16 plugin's for playin mobsters on myspace. After capturing the the script, editing & placing in the address bar I recieve a message: Failed Security. This XML file does not appear to have any style information associated with it. The document tree is shown below. There was nothing on the Tree. I know the script was edited correct cause it works on the other PC's. Operating system is win7 & Firefox is current. Thx.
    == The first time

    yea I got the same error for playing files on filestube and its just not that, ever since 2 days ago when I updated firefox everything have just started to ..uck up all the time, high cpu memory load without any addons and it wont terminate for another 20secs after I close it... I think I'll just reinstall with an older version, everything worked just fine then

  • How should you head up an XML file?

    Hi
    I'm just wondering if it's imperitive to place...
    <?xml version="1.0" encoding="utf-8"?>
    at the top of XML files?  Can you just use <XML> ?
    I ask, as I'm using Flash and PHP to create an XML file.  It all works, but I notice that where I want to include quotes (single or double), either Flash or PHP is adding slashes, so you end up with...
    <?xml version=/"1.0/" encoding=/"utf-8/"?>
    I can't find a way to solve that problem, so am wondering if it's ok to take that line out altogether?  It works, but I want to make sure it's not needed.
    Thanks for your help guys.
    Shaun

    It's likely that you have PHP Magic Quotes enabled on your server.  You should disable that function or ask your host to do it for you.
    http://php.net/manual/en/security.magicquotes.php

  • How to retrieve image from XML  file

    Hi All,
    I am new to XML. So any best guidance is appreciated.
    The application requirement is to display image retrived from uploaded xml file in file upload section of our application. And store that image in database.
    In my XML file , images & strings & numbers & booleans are there . I am able to save everything in database except images .
    I am using JSF, Seam & Hibernate combination. In my Hibernate entity class i took BLOB datatype for image.
    I am using following tags in my Xhtml file to display image
    <s:graphicImage value="#{hibernateentitybean.picBlobtype}" height="200" width="200">
    <s:transformImageSize width="200" height="200" />
    <s:transformImageType contentType="image/jpeg"/>
    But image is not displayed in Xhtml file
    I am using org.w3c.dom.Document for retrieving node name & corresponding value in that node in XML file.
    I am getting code like below for Image when i am logging all values from XML files in my bean class .
    x0lGQRQAAAABAAAAAAAAAFJHAQARAAAAVwBhAHQAZQByACAAbABpAGwAaQBlAHMALgBqAHAAZwAAAP/Y/+AAEEpGSUYAAQIBAGAAYAAA/+0YLl
    I want to convert this value to image. So i can convert image to bytes and store in BLOB.
    Can anyone guide me ? or any other approach .
    Thanks in advance for any reply.
    Regards,
    Naresh

    Dan_Koldyr wrote:
    agree, it's really odd. Just reread OP and it says:
    NareshDharmiVatsal  wrote:
    want to convert this value to image. In any case it doesn't get worth then another single code line:
    final String cdata = "x0lGQRQAAAABAAAAAAAAAFJHAQARAAAAVwBhAHQAZQByACAAbABpAGwAaQBlAHMALgBqAHAAZwAAAP/Y/+AAEEpGSUYAAQIBAGAAYAAA/+0YLl";
    final sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
    final byte[] data = decoder.decodeBuffer(cdata);
    Blob blob = new SerialBlob(data);//or what ever other DB-specific blob implementaiton Did i answered original question? Any more comments to my first replay?I can comment on this latest code. The package sun.misc is private to Sun (Oracle now of course). It is undocumented and may change or be removed altogether in a future release. There is a good free open source Base64 decoder in the Jakarta Commons Codec library.

  • Delete elements from XML file using DOM and java

    Hi
    I want now is to remove element from my XML file
    for example
    i have following xml
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
              <firstLineText />
              <firstLineText>|line11</firstLineText>
              <firstLineText>|line12</firstLineText>
    </firstLineTexts>
    </printing>how do i remove all elements fireLineText
    my final output should be
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
    </firstLineTexts>
    </printing>How do i do it using DOM,
    I can create instance of DOM and write it using TransformerFactory
    Ashish

    Hi
    I am trying the following code,
    but it is not working
                    NodeList nScene = doc.getElementsByTagName("firstLineTexts");
              NodeList nScene1 = nScene.item(0).getChildNodes();
              for (int i = 0; i < nScene1.getLength(); i++)
                   Node n = nScene1.item(i);
                        nScene.item(0).removeChild(n);
              }

  • How to read the content in one node of XML in Java? Pls help

    My dear brothers,
    I am a newbie of XML, I have a exercise which is creating a Tree View from XML file. But the trouble is I do not know how to read the content in one node of XML file. I decide to use the algorithm as following:
    1. Create a GUI form which gives the ability for user to choose a XML file (ok)
    2. Load XML and return the file (ok)
    3. Read the file from node to node to create the node in Tree View (?!)
    Please help me, and if you are enough kind, please give me an small example to easy understand. Thanks in advance.
    Hoang Yen Binh

    I hope this one helps you.
         <ABC Type="ProductBased" ProdName="One" Location="India">
              <CEO>Raj</CEO>
              <Finance>Vikram</Finance>
              <HR>Karthik</HR>
              <Technical>Satish</Technical>
         </ABC>
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Attr;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.w3c.dom.DOMException;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import java.io.File;
    import java.io.IOException;
    public class XmlReading {
         Document doc;
         Element element;
         public static void main(String[] args) throws Exception{
              XmlReading xr = new XmlReading();
              xr.getXmlParser(args);
         public void getXmlParser(String[] args) {
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   if(args.length != 1) {
                        System.err.println("Argument Required");
              try {
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   doc = builder.parse(new File(args[0]));
              }catch(ParserConfigurationException e1) {
              }catch(SAXException e2) {
              }catch(IOException e3) {
              getAttributes();
         public void getAttributes() {
              // Retrive the entire Document from the Dom Tree
              element = doc.getDocumentElement();
    //          System.out.println(element);
              NamedNodeMap attrs = element.getAttributes();
              // Get number of attributes in the element
         int numAttrs = attrs.getLength();
         // Process each attribute
              for (int i=0; i<numAttrs; i++) {
                   Node node = attrs.item(i);
                   // Get attribute name and value
                   String attrName = node.getNodeName();
                   String attrValue = node.getNodeValue();
                   System.out.println(attrName + ": " + attrValue);
              String s1 = element.getTagName();
              System.out.println(s1);
              // To get all the elements in a DOM Tree
              NodeList nl1 = element.getElementsByTagName("*");
              int i2 = nl1.getLength();
              System.out.println(i2);
              for(int i=0; i<i2; i++) {
                   System.out.println(nl1.item(i) + "\n");
    }

Maybe you are looking for

  • Flash crashes on launch

    I'm trying to demo Flash CC 2014 and have downloaded it and installed it. When I try to launch it, it quits immediately.  Looking for help. Running on MBP Pro 15 Retina, Late 2013 with OS 10.9.4 I have the CC 6 Full suite of apps installed.

  • Issue with Fiscal Year Varient Period modifications for 2012

    Hi All, Can you please advice how the Fiscal Year Varient modified periods be transported to different clients. The issue is, we have 2012 Periods already setup in DEV and transported to QAS and PRD, now the clinet came up with different periods for

  • Preventing root from overwriting a file

    Is there any way to keep pacman (or other package managers that run as root) from overwriting a file in a directory where it would normally be overwritten? Without using the immutable flag (which only works on ext* filesystems)? I know this should st

  • Why we use exception ???

    Why we use Exception ??anyone knows what are the 3 keys point below describe about..?? There are 3 main Advantages of using Exception 1.Separates error handling code from "regular code 2.Propagating erros up the call stack (without tedious programmin

  • CIAC-CPSC Portal Session cookie problem on weblogic

    Hi all, I´m currently working on a CIAC project with some development made by a partner, the thing is they are using a cookie generated by the application server called "Cognoscookie", with that they use the session ID to run some queries from a port