How to SAVE a updated XML DOM Data to the file?

Hi
I am able to load an XML file into a XML DOM object using JAVA (xerces). I have update the required data in the DOM.
But I am NOT able to save back the data to the physical file.
Will appreciate if you can help me ASAP.

Hi Krishar,
Check out the jaxp new release on java.sun.com. This api has classes and methods to help you do the same.
sample code:
     try
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          java.net.URL url = this.getClass().getResource(XML_FILE);
          java.io.File thsFile = new java.io.File(url.getFile());
          DocumentBuilder builder = factory.newDocumentBuilder();
          TransformerFactory tFactory = TransformerFactory.newInstance();
          Transformer transformer = tFactory.newTransformer();
          document = builder.parse(thsFile);
//You can do any modification to the document here
          DOMSource source = new DOMSource(document);
          StreamResult result = new StreamResult(thsFile);
          transformer.transform(source, result);
     catch (TransformerConfigurationException tce)
          System.out.println("\n** Transformer Factory error");
          System.out.println(" " + tce.getMessage());
          Throwable x = tce;
          if (tce.getException() != null)
               x = tce.getException();
          x.printStackTrace();
     catch (TransformerException te)
          System.out.println("\n** Transformation error in add:");
          System.out.println(" " + te.getMessage());
          Throwable x = te;
          if (te.getException() != null)
               x = te.getException();
          x.printStackTrace();
     catch (SAXException sxe)
          System.out.println("sax exp" + sxe.getMessage());
     catch (Exception ex)
          System.out.println("exc exp" + ex);
          ex.printStackTrace();
Hope this will help you XML_FILE is constant representing the path of the file. It should be in classpath. The program essentially parsing a xml file and creating dom document and then writing it back to the same file. you can do any modifications/write to other file etc...
Think this will suffice your requirement
bye
take care
Hi
I am able to load an XML file into a XML DOM object
using JAVA (xerces). I have update the required data
in the DOM.
But I am NOT able to save back the data to the
physical file.
Will appreciate if you can help me ASAP.

Similar Messages

  • How to save and retrive XML DOM to/from SQLServer

    Hi, there,
    I am new to JAVA, and now I'm trying to save a large XML DOM to SQLServer, and retrive it as a XML DOM later. Would someone please let me know how can I do it?
    Thanks!
    ----YM

    You would be better looking at the XML DOM documentation for your database rather than asking here. If your DB doesn't provide XML facilities, then there are products and techniques that can be applied to map XML to SQL, and you can always serialize the java objects into a blob, but XML to SQL mapping isn't standardized, so the first call is the server's documentation.

  • How to save output image after IMAQ-FFT to the file

    When I apply IMAQ FFT on monochromatic image and display complex destination image by IMAQ WindDraw, I get picture which I am not able to save to the file. I tried various conversions from complex image to bitmap (array), but result was everytime different from that got by IMAQ WindDraw.
    I thank for any help.

    Hallo Filip,
    you cannot save Complex Image to file to be readable by other programs - see link: http://digital.ni.com/public.nsf/websearch/D557B1A79C30AD5F86256AB1006A678A?OpenDocument
    What you can do is convert Complex Image to 8-bits BMP file format and save it then. This question was answered already - see example at: http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3ECED56A4E034080020E74861&p_node=DZ52000_US&p_source=External
    Hope this helps
    Pavel

  • How to save info in a meta-data of a jpg file?

    hi, i need to know how to save info in a meta-data of a jpg file:
    this is my code (doesn't work):
    i get an exception,
    javax.imageio.metadata.IIOInvalidTreeException: JPEGvariety and markerSequence nodes must be present
    at com.sun.imageio.plugins.jpeg.JPEGMetadata.mergeNativeTree(JPEGMetadata.java:1088)
    at com.sun.imageio.plugins.jpeg.JPEGMetadata.mergeTree(JPEGMetadata.java:1061)
    at playaround.IIOMetaDataWriter.run(IIOMetaDataWriter.java:59)
    at playaround.Main.main(Main.java:14)
    package playaround;
    import java.io.*;
    import java.util.Iterator;
    import java.util.Locale;
    import javax.imageio.*;
    import javax.imageio.metadata.IIOMetadata;
    import javax.imageio.metadata.IIOMetadataNode;
    import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
    import javax.imageio.stream.*;
    import org.w3c.dom.*;
    public class IIOMetaDataWriter {
    public static void run(String[] args) throws IOException{
    try {
    File f = new File("C:/images.jpg");
    ImageInputStream ios = ImageIO.createImageInputStream(f);
    Iterator readers = ImageIO.getImageReaders(ios);
    ImageReader reader = (ImageReader) readers.next();
    reader.setInput(ImageIO.createImageInputStream(f));
    ImageWriter writer = ImageIO.getImageWriter(reader);
    writer.setOutput(ImageIO.createImageOutputStream(f));
    JPEGImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault());
    IIOMetadata metaData = writer.getDefaultStreamMetadata(param);
    String MetadataFormatName = metaData.getNativeMetadataFormatName();
    IIOMetadataNode root = (IIOMetadataNode)metaData.getAsTree(MetadataFormatName);
    IIOMetadataNode markerSequence = getChildNode(root, "markerSequence");
    if (markerSequence == null) {
    markerSequence = new IIOMetadataNode("JPEGvariety");
    root.appendChild(markerSequence);
    IIOMetadataNode jv = getChildNode(root, "JPEGvariety");
    if (jv == null) {
    jv = new IIOMetadataNode("JPEGvariety");
    root.appendChild(jv);
    IIOMetadataNode child = getChildNode(jv, "myNode");
    if (child == null) {
    child = new IIOMetadataNode("myNode");
    jv.appendChild(child);
    child.setAttribute("myAttName", "myAttValue");
    metaData.mergeTree(MetadataFormatName, root);
    catch (Throwable t){
    t.printStackTrace();
    protected static IIOMetadataNode getChildNode(Node n, String name) {
    NodeList nodes = n.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
    Node child = nodes.item(i);
    if (name.equals(child.getNodeName())) {
    return (IIOMetadataNode)child;
    return null;
    static void displayMetadata(Node node, int level) {
    indent(level); // emit open tag
    System.out.print("<" + node.getNodeName());
    NamedNodeMap map = node.getAttributes();
    if (map != null) { // print attribute values
    int length = map.getLength();
    for (int i = 0; i < length; i++) {
    Node attr = map.item(i);
    System.out.print(" " + attr.getNodeName() +
    "=\"" + attr.getNodeValue() + "\"");
    Node child = node.getFirstChild();
    if (child != null) {
    System.out.println(">"); // close current tag
    while (child != null) { // emit child tags recursively
    displayMetadata(child, level + 1);
    child = child.getNextSibling();
    indent(level); // emit close tag
    System.out.println("</" + node.getNodeName() + ">");
    } else {
    System.out.println("/>");
    static void indent(int level) {
    for (int i = 0; i < level; i++) {
    System.out.print(" ");
    }

    Hi,
    Yes, you need store data to table, and fetch it when page is opened.
    Simple way is create table with few columns and e.g. with CLOB column and then create form based on that table.
    Then modify item types as you like, e.g. use HTML editor for CLOB column
    Regards,
    Jari

  • How to save downloaded update installer files

    How can I locate a downloaded update installer file so I can save it and use to install on another mac without having to download all over again?  Today I downloaded updates for OS X and also for Office 2011.  The first is over 2GB and the second around 300MB.  I have installed on my Macbook Pro, but I have another 3 units to update. I live in a 3rd world country with very slow internet and it takes me days to download such files.

    Grateful for you having replied but for some reason I seem unable to open your message "Re: How to save downloaded update installer files".  Waikato99

  • How to read value within XML Tag data using IO Stream in Java

    We have xml data into a Stream and we need to extract values again into a Stream from the particular XML tag <Data> inside the Stream. PFB the sample XML which will be contained inside the stream and can someone help us to hint the java code for this. We require it using the IO API only and we need to look <DATA> for the begining of the stream and </DATA> as the end of the stream.
    Please note that input is stream and output require also is a stream.
    <?xml version = "1.0" encoding="UTF-8" ?>
    <GenericDataEnvelope>
    <DataFormat>PlainText</DataFormat>
    <Name>1111</Name>
    <Security>NA</Security>
    <senderName>abc</senderName>
    <Protocol>HTTP</Protocol>
    <Data>
    SElQRlhDVElQRlBCTktERUZGMDYxMDAyMDc0MzUyMDAwMTA2MTAwMjA3NDM1MlRDSEFTVVMzMzAw
    MDAwMDAwMDAwMTc4LDEyMDAwMTc4MTIKezQ6TVQxMDM6CjoyMDowMDYwMDQ5MjQxMDA2NzcwCjoy
    M0I6Q1JFRAo6MjNFOlNEVkEKOjMyQTowNjEwMDVDQUQwLDAxCjozM0I6RVVSMCwwMQo6MzY6MSwz
    TNzcwQU5WLVJFTlRFIE9DVCAwNgowLDAxLzEsMTcxOQo6NzFBOlNIQQo6NzI6L1JFQy84NDM2MTU3
    MTA2Ci19ClRJUEYK
    </Data>
    <DataType>INVOICE</DataType>
    </GenericDataEnvelope>

    The example you've showed is valid and it is also text.
    Think seriously about this ... for example, do you have a rule that says </DATA> can't appear in the binary data?
    But in any case I can't see the problem. If you want to use IO classes directly, just read lines until you see <DATA>, then read data until it ends with </DATA>, and remove that.
    But I would certainly use SAX myself until proven otherwise that it won't work..

  • Save the data in the file as json data

    Hello,
    I need to read data from list / Pictures gallery / Documents  and save the returned data  in the file as json data .
    How Can I Implement that .
    ASk

    Try below:
    http://msdn.microsoft.com/en-us/library/office/jj164022%28v=office.15%29.aspx
    The code in the following example shows you how to request a JSON representation of all of the lists in a site by using C#. It assumes that you have an OAuth access token that you are storing in the
    accessToken variable.
    C#
    HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + "/_api/web/lists");
    endpointRequest.Method = "GET";
    endpointRequest.Accept = "application/json;odata=verbose";
    endpointRequest.Headers.Add("Authorization", "Bearer " + accessToken);
    HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
    Getting properties that aren't returned with the resource
    Many property values are returned when you retrieve a resource, but for some properties, you have to send a
    GET request directly to the property endpoint. This is typical of properties that represent SharePoint entities.
    The following example shows how to get a property by appending the property name to the resource endpoint. The example gets the value of the
    Author property from a File resource.
      http://<site url>/_api/web/getfilebyserverrelativeurl('/<folder name>/<file name>')/author
    To get the results in JSON format, include an Accept header set to
    "application/json;odata=verbose".
    If this helped you resolve your issue, please mark it Answered

  • Remote and direct update of master data at the same time

    Hello
    Is it possible to do remote and direct update of master data at the same time? If yes where it could be used?
    Thanks

    Hi,
    What do you mean by Remote Update ?
    regards
    Happy Tony

  • Recently had to purchase a replacement phone a friend of mine had backed up the data on the lost phone to his Mac laptop how do I get that backed up data from the lost iPhone that's on his Mac laptop to my new replacement phone? Please give step by step

    recently had to purchase a replacement phone a friend of mine had backed up the data on the lost phone to his Mac laptop how do I get that backed up data from the lost iPhone that's on his Mac laptop to my new replacement phone? Please give step by step instructions xoxoxo
    And my iTunes sign in is also screwed up... It is underneath my friends email (the one with my backed up data on his Mac laptop) HOW DO I CHANGE THIS SO THAT I CAN DOWNLOAD APP's again...

    I suspect unless he had some items in iCloud backup then they are gone.  Connecting an iPhone to a different library from that to which it was previously connected will result in the device asking if you want to erase it.

  • The uploaded file CPSIDRPT.xml is invalid. The file should be in XML-DATA-T

    can someone explain me why am I getting following error message when I'm trying to upload a data defination file?
    The uploaded file CPSIDRPT.xml is invalid. The file should be in XML-DATA-TEMPLATE format.
    thanks........
    ketki----

    Based on the detail (or lack of) that you have provided, your file is not in the right format.
    Can you open the file in a internet browser? Is it well-formed XML?
    Edited by: SIyer on Dec 1, 2009 4:33 PM

  • How to print out the data from the file ?

    hi all,
    i have upload my file to here :
    [http://www.freefilehosting.net/ft-v052010-05-09 ]
    anyone can help me to print out the data from the file ?
    the content of the file should be like this :
    185.56.83.89 156.110.16.1 17 53037 53 72 1
    and for the seven column is
    srcIP dstIP prot srcPort dstPort octets packets

    hi all,
    i have try to do this
    public static void Readbinary() throws Exception
              String file = "D:\\05-09.190501+0800";
              DataInputStream dis = new DataInputStream(new FileInputStream(file));
              //but then how to read the content ??????can you give me more hint ?????
    i have find the netflow v5 structure by C
    struct NFHeaderV5{
    uint16_t version; // flow-export version number
    uint16_t count; // number of flow entries
    uint32_t sysUptime;
    uint32_t unix_secs;
    uint32_t unix_nsecs;
    uint32_t flow_sequence; // sequence number
    uint8_t engine_type; // no VIP = 0, VIP2 = 1
    uint8_t engine_id; // VIP2 slot number
    uint16_t reserved; // reserved1,2
    struct NFV5{ 
    ipv4addr_t srcaddr; // source IP address
    ipv4addr_t dstaddr; // destination IP address
    ipv4addr_t nexthop; // next hop router's IP address
    uint16_t input; // input interface index
    uint16_t output; // output interface index
    uint32_t pkts; // packets sent in duration
    uint32_t bytes; // octets sent in duration
    uint32_t first; // SysUptime at start of flow
    uint32_t last; // and of last packet of flow
    uint16_t srcport; // TCP/UDP source port number or equivalent
    uint16_t dstport; // TCP/UDP destination port number or equivalent
    uint8_t pad;
    uint8_t tcp_flags; // bitwise OR of all TCP flags in flow; 0x10
    // for non-TCP flows
    uint8_t prot; // IP protocol, e.g., 6=TCP, 17=UDP, ...
    uint8_t tos; // IP Type-of-Service
    uint16_t src_as; // originating AS of source address
    uint16_t dst_as; // originating AS of destination address
    uint8_t src_mask; // source address prefix mask bits
    uint8_t dst_mask; // destination address prefix mask bits
    uint16_t reserved;
    but how to translate the structure to java,then get the data from the file ?
    Edited by: 903893 on Dec 21, 2011 10:52 PM

  • How to save SOME time machine Mac backups from the TM disk to other disk WITHOUT formatting the destination disk?

    Hi,
    How to save SOME time machine Mac backups from the TM disk to other disk WITHOUT formatting the destination disk?
    I have a Time Machine disk (A) including the backups of several different Macs (B, C, D & E) generated with an old Mac OS X 10.5.8 (iMac PowerPC) over the years.
    I have transferred the old Mac contents to a new Mac with OS X 10.8.3 using Migration Assitant. All OK.
    Now, I want to erase such TM disk A to use if for other purposes, but first, I would like to RECOVER the backups of some Macs inside it (D and E). Is that possible WITHOUT formatting the destination disk and selecting only some Macs from the TM disk and not the fulll TM disk? How?
    Thanks.

    Thanks for the reply. I do not think that is messy, anway. I simply used the same external disk as Time Machine disk for different Macs. And that worked OK all the time for years.
    The ExternalTimeMachineDisk contains the folder Backups.backupdb
    which contains the following folders (each one corresponding to the Time Machine backup made from each Mac):
    Mac1
    Mac2
    MacBook1
    MacBook2
    In relation to my message above, is it possible to select specific files, folders or full Mac backups from such Time Machine disk and save them to other disk? How?
    Thanks.

  • The uploaded file .xml is invalid. The file should be in XSD format.

    hi ,
    when i am trying to upload a data definition file .ie salesinvoice.xml through oracle XML Publisher , i get the error message "The uploaded file salesinvoice.xml is invalid. The file should be in XSD format."
    i tried attaching other xml files also and i get the same error message. don't know how to fix this . the rtf files i can attach without and problem.
    thanks in advance
    manohar

    This totally worked for me. Strange enough, any heads-up on whether this has been patched or not for versions 12.0 + ?
    Edited by: user8961526 on Nov 22, 2010 12:24 PM

  • Regarding reading the data from the files without using Stremas

    hai to all of u...
    here i have a problem where i have to read the data from the files without using any streams.
    please guide me how to do this one,if possible by giving with an example
    Thanks & Regard
    M.Ramakrishna

    Simply put, you can't.
    By why do you need to?

  • Vaildating File name with the data in the file using sender file adapter

    Hi,
    Below is the scenario
    1)       Pick up files from a FTP server, the file name is dynamic, how do I put dynamic name in sender file adapter?
    2)       Determine if the user correctly named the file based on data in the file.
    a.       File naming structure that we will be concerned with is <company_code><accounting_time_period>.<extension>
    b.      The company code and the time period in the file name have to match the data in the file.
    i.      For example.  If the file name is 1001_200712.csv and the data in the file is for company code 1005, time period 200712, the file is incorrectly named.  Both values must be correct.
    How do we do this?

    Hi Sachin,
                    As Rightly said by Krishna, You can not put Dynamic name in sender File Adapter .You have to provide the name of the file like "*.txt" in Sender Adapter and at runtime you can access this file name by using following UDF:
    DynamicConfiguration conf  = (DynamicConfiguration) container
      .getTransformationParameters()
      .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String valueOld = conf.get(key);
    return (valueOld);
    As now you have picked up the file name at runtime.
    Now concatenate source file fields Company_code and Accounting_timeperiod using "_" as delimiter in properties.Also concat the extension .Now you have required file name.
    So using EQUALS standard function ,compare it with File Name fetched at runtime using above given UDF, and pass result as you desire to process further or not or to raise Alert to resend the file.
    Thanks & Regards,
    Anurag Garg
    You can validate this file name in Mapping itself.

Maybe you are looking for

  • Possible fixes to install/update Flash Player in IE 9

    OK just spent a couple of hours attempting to get IE 9 (32-bit) to install Flash 10.2.153.1. Tried all the troubleshooting advice - turned off security, etc. Problem: When clicked on download button, the download page would come up but nothing happen

  • How to increase number of email messages displayed in my inbox

    I have three 3 email acounts and one of them does not display all my recent messages.  I suspect there is a setting to display 1000 messages (or similar) I cannot find this anywhere doing a "search" I am using Apple Mail. Ironically using Thunderbird

  • Iphone notes won't display attached pdf

    I can create a note with an attached PDF (dragged from a Finder window) on my Mac laptop (10.9.4).  The note is synced through iClound and the attachment can be seen and opened on a second Mac laptop (10.9.4). On my iPad Air (IOS7) a paperclip symbol

  • Setting time or time server on clients with ARD

    Does anyone know what files need to be copied to OS X clients to set their time or time server? I know that time server info is stored in /etc/ntp.conf, but this isn't the only file that needs to be sent to set up a client to get its time from a time

  • Problem 'Comments Share is not defined'

    Hello, I've just published my website and when I go on it (with Safari or Firefox) there is this message in every 'multimedia' page : Reference Error - Comments Share is not defined. I did not select the 'comments' functions in the inspector. So, I'm