Writing out subtree of the DOM

Hi,
I would like to save a subtree of DOM tree in the file.
I want my output to be well-formed, except it should
not contain xml header in it.
Is there a way to do that?
Thanks for your help.

Transformer transformer = TransformerFactory.newInstance().newTransformer();
FileWriter sw = new FileWriter("c:/myfolder/myfile.xml", false);
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.transform(new DOMSource(myNode), new StreamResult(sw));
sw.flush();
sw.close();with myNode being the element root of your subtree.

Similar Messages

  • [svn] 2710: Fixed 3.1. 0 by reverting to the old behaviour when writing out debug

    Revision: 2710
    Author: [email protected]
    Date: 2008-08-01 14:12:55 -0700 (Fri, 01 Aug 2008)
    Log Message:
    Fixed 3.1.0 by reverting to the old behaviour when writing out debug
    line numbers. This prevents the player from seeing -1, which was
    causing hangs/crashes. The real fix is to track down where synthetic
    functions are getting generated and make them not debuggable, so they
    don't reuse the debug line numbers from previous debuggable functions.
    This will be done in trunk in a follow on checkin.
    tests Passed: checkintests
    Needs QA: YES
    Needs DOC: NO
    Bug fixes: SDK-16323
    API Change: NO
    Reviewer: jspiro
    Code-level description of changes:
    Modified setPosition() and clearPositionInfo() to no longer set the
    debug_linenum to -1.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-16323
    Modified Paths:
    flex/sdk/branches/3.1.0/lib/asc.jar
    flex/sdk/branches/3.1.0/modules/asc/src/java/macromedia/asc/embedding/avmplus/ActionBlock Emitter.java

    April, We are aware of this problem and the fix is being coded as I write this message.
    -Prasad

  • HOWTO: Writing Out XML Query Results of Any Size in Java with XML SQL Utility

    A customer mailed me asking for an example of how to use our XML SQL Utility to write out query results for tons of query result rows.
    With tons of data, the getXMLDOM() and getXMLString() methods are not really appropriate due to the size.
    The XML SQL Utility offers a getXMLSAX() method that streams SAX2 events to report the data being queried. This is the approach we can use to handle data of any size.
    It dawned on me today that by putting together the XML SQL Utilities getXMLSAX() routine, and the oracle.xml.parser.v2.XSLSAXPrintDriver SAX2 ContentHandler, we can effectively stream out data of any length to an appropriate writer.
    Here's a code example to get the point across:
    package test;
    import java.io.BufferedOutputStream;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.Properties;
    import javax.xml.transform.OutputKeys;
    import oracle.jdbc.OracleDriver;
    import oracle.xml.parser.v2.XSLException;
    import oracle.xml.parser.v2.XSLOutput;
    import oracle.xml.parser.v2.XSLSAXPrintDriver;
    import oracle.xml.sql.query.OracleXMLQuery;
    public class Example  {
      private static final String QUERY = "select * from emp";
      public static void main(String[] args) throws Throwable  {
          Connection conn = getConnection();
          OracleXMLQuery q = new OracleXMLQuery(getConnection(),QUERY);
          // Any printwriter will do. Here's we're output to standard out.
          PrintWriter output = new PrintWriter(new BufferedOutputStream(System.out));
          // This is a SAX2 Content Handler used by the Oracle XSLT Engine
          // to serialize a stream of sax2 events as an XML document
          // We'll use it to serialize the sax2 events from the XML SQL Utility
          // out as an XML document.
          XSLSAXPrintDriver ch = new XSLSAXPrintDriver(output, outputOptions());  
          // This asks XML SQL Utility to fire sax events for the data
          // being fetched instead of creating DOM nodes or returning text.
          // By using the XSLSAXPrintDriver content handler, these events
          // get handled by writing them directly to the output stream
          q.getXMLSAX(ch);
          ch.flush();
          q.close();
          conn.close();     
      private static XSLOutput outputOptions() throws XSLException {
        XSLOutput x = new XSLOutput();
        Properties props = new Properties();
        props.put(OutputKeys.METHOD,"xml");
        props.put(OutputKeys.INDENT,"yes");  // Set to "no" for non-indented
        x.setProps(props);
        return x;
      public static Connection getConnection() throws SQLException {
        String username = "scott";
        String password = "tiger";
        String thinConn = "jdbc:oracle:thin:@localhost:1521:ORCL";
        Driver d = new OracleDriver();
        return DriverManager.getConnection(thinConn,username,password);
    }

    Hi Uber,
    This is a known issue that error occurs when running report "Count of instances of specific software registered with Add or Remove Programs" due to non-printable characters for XML. Based on internal research, the hotfix for this issue will be
    included in the System Center 2012 Configuration Manager Service Pack 1.
    As a workaround, you can remove the nonprintable character populated into the report parameter by referring to the following KB article:
    http://support.microsoft.com/KB/914159
    Hope this helps.
    Regards,
    Mike Yin
    Mike Yin
    TechNet Community Support

  • To avoid writing database code in the front end

    Hello,
    I am working on a database application using 10g database as backend and dotnet as front end. I wish to execute only oracle stored procedure for all the select (to avoid hard parse and use of bind variable), DDL and DML operations; just to avoid writing database code in the front end. Can anyone please give me a little examples of :
    1.Select query's output to be return as resultset by stored procedure.
    2.DML example by stored procedure.
    3.Any DDL example by stored procedure.
    using scott.emp, so that i would just call the stored procedure, rather than giving select,DML and/or DDL commands in the front end. Even though i have read in the documentation, but a clear cut examples will help me to get into clear concept as well.
    Thanks & Regards
    Girish Sharma

    Hi...
    -->Select example
    create or replace procedure get_emp(rc out sys_refcursor)
    is
    begin
    open rc for select * from emp;
    end;
    -->DML example
    create or replace procedure do_dml_emp(pempid in number,
    pempname varchar2,
    result out number)
    is
    begin
    insert into emp(empid,empname) values(pempid,pempname) returning empid into result;
    exception
    when others then
    result:=-1;
    end;
    -->DDL example
    create or replace procedure ddl_emp(colname varchar2,
    coltype varchar2,
    result out number)
    is
    begin
    result:=-1;
    execute immediate 'alter table emp add column ' || colname || ' ' || coltype ;
    result:=1;
    end;

  • Special characters in XML built using the DOM object

    I am using the DOM object to build xml but I am having problems with special characters. I have a Element object that I create attributes in. Most special characters like the &, ", or ' are translated for me (amp; quot;, acute; put a & in front of those, if I do it here the browser will translate them into the logical character) but I am having a problem with the � character. The DOM object does not translate this. If I do it my self to(eacute; same here add a & in front) before adding the string to the attribute then the DOM object translates it to (amp;eacute; add a & in front of the amp; not in front of the eacute;). As you can see the DOM object translates the & instead of recognizing that it is a HTML character. Can anyone give me a hand?

    I am building this XML in a servlet so ,right, DOM does process XML (even though a valid HTML file can be loaded into a DOM object) but if you build XML using DOM then write the XML out using PrintWriter and Transformer objects this will cause the XML to print out in your browser. If you view source on this XML you will see that the DOM object has translated all special characters to there &xxxx; equivalent. For a example: when the string (I know "cool" java) gets loaded into a attribute using the DOM object then wrote back out it looks like (I know &xxx;cool&xxx; java) if you view the source in your browser. This is what it should do, but the DOM object is not change the � to the "&xxxxx;". This servlet is acting as a gateway between a Java API and a windows asp. The asp will call the servlet expecting to get XML back and load it directly into a DOM object. When the windows DOM object gets the xml that I am returning in this servlet is throws a exception "invalid character" because the � was not translated to &xxxx; like the other characters were. According to the book HTML 4 in 24 hours (and other references) the eacute; or #233; are how you say "�" in HTML or XML. How do you say it?

  • The DOM Hierarchy Viewer needs to be larger

    As I build bigger and more complex files in reflow rearranging things can be a nightmare in the the tiny popup DOM inspector. It only shows a few items at a time and dragging things up and down within it is really hard without accidentally moving out and having it close.
    It should be a full height item on the right side of the window like a maximized layers palette in Illustrator or Photoshop. That would allow you to see things in context as well as easily move them around when you're rearranging for various reasons…
    At the very least it should be resizable so that you can see more than a few rows at a time and you don't have to constantly toggle parent open and closed to see what's what.

    Hey,
    I can can tell you we're already working on the popping and difficulty with resorting using the DOM panel. We've also been exploring ways to make it stay up all the time, as well as behave like layers as you suggested. Stay tuned, and thanks for your input!

  • [svn] 1941: Fix bug with writing out a MorphShape2 line style when it has a fill

    Revision: 1941
    Author: [email protected]
    Date: 2008-06-04 12:13:17 -0700 (Wed, 04 Jun 2008)
    Log Message:
    Fix bug with writing out a MorphShape2 line style when it has a fill
    connected to it. Had been calling encodeMorphFillstyles() directly
    with an array of one element, but that adds a count byte (of value 1)
    which should not be there. So I decomposed new method
    encodeMorphFillstyle() out of encodeMorphFillstyles(). So not a big
    change, but lots of indentation changes.
    Other than that all changes were replacing the use of constant numbers
    with static constants from FillStyle and also adding an equals()
    implementation for FocalGradient.
    reviewed by Pete Farland, passed flex checkin tests
    Modified Paths:
    flex/sdk/trunk/modules/swfutils/src/java/flash/swf/TagDecoder.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/swf/TagEncoder.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/swf/types/FocalGradient.java

    Hello,
    We also have this problem ...
    We are concluded, (??) When there is a note on the first or second line that starts in the block, justification and rebuilt and the problem happens! even made to change color of text on the blank page occurs ... our solution to an extra line at the beginning of the block without note or make it past the note on the previous page ...
    when in a true solution?
    Translation from French
    Bonjour,
    Nous avons aussi ce problème …
    Nous somme arrivé à la conclusion, (???) quand il y a une note sur la première ou la deuxième ligne qui commence dans le bloc, justification et refaite et le problème arrive !!! même le faite de changé de couleur sur du texte les page blanche survient … notre solution mettre une ligne supplémentaire en début du bloc sans note ou faire passé le note sur la page précédente …
    à quand une vrai solution?
    Philippe

  • How and from where can I download the dom API?

    I'm looking to use the functionality in the dom API, to convert a html document to dom and then traverse it and pull out any information I require from the tree-like dom structure. I've been told that the best way to do this is to use the dom package, but where do I get it from? Because it is not incorporated into the standard Java 1.4 that I have on my machine.
    Any help would be great.
    Cheers
    Anjum

    I don't believe it works at all in 1.4 other than the simple
    "get the title of the html documnent" example they show.
    Bug 4803577 aggregates all the dom bug reports. There are alot.
    This bug report indicates the fixes are in 1.5.

  • Help to find out some of the object model for InDesign preference

    Hi All,
    I'm writing script to update the specific client preferences for each and every preferences of InDesign CS5. I couldn't find some of the object models in Extendscript help. If someone knows, please help to find out this.
    These are the list. Also refer screenshot.
    1. Dictionary Preference - Language English: USA
                                          Hyphenation
                                          Spelling
                                          Double Quotes 
                                          Single Quotes 
    2. Autocorrect Preference - Language English: USA
    3. File Handling Preference - Default Relink Folder
    Many thanks in advance.
    Peru.

    I looked and was not able to find a way to do this.

  • Hangs on Writing Out and comes up black after burn.

    Hello All,
    I just tried to burn a project of mine twice. Both times I could see iDVD rendering my menus, etc. It will burn rather quickly and will hang on "writing out...." before it spits out the DVD. I dont get any errors, and the DVD shows up when I insert it. However, the DVD just comes up as a black screen. If i hit the menu button in DVD Player, it will say "not permitted" and I cant see anything but a black screen. When I take the DVD out i can see that its been written to. The back of the DVD has a nice black ring around it from being written to. I am using DVD-R media. Also, when i look at my project stats it doesnt say that I have used up any space, but everything looks great when I preview it before burning.
    Thanks,
    -- Steven

    Suggest you create a disc image and then burn the DVD. File/Save As Disc Image...
    http://docs.info.apple.com/article.html?artnum=164927
    This will isolate any encoding/burning issues you may encounter. Once the disc image is created, double-click the .img and burn the virtual disc that should appear on your desktop, using Toast to burn the DVD. Disk Utility to burn the .img file. Usually, you can select a burning speed in Disk Utility.
    Open Disk Utility (in Utilities folder in Applications folder), click on the virtual disc (not the .img, the one below) in the left-hand window. Click the Burn icon. Your SuperDrive tray will open. Insert a recordable DVD. (DVD-R preferred by me.) Click the Close button. Wait. Then click the Burn button.
    -->If the virtual disk selection won't allow you to click the Burn icon, use the .img file instead. This may have changed in 10.3.9 and did change in Tiger.
    b Also, you can use DVD Player to play the virtual disk to check your iDVD 5 project before burning to DVD. Launch DVD Player. File/Open VIDEO_TS (Open DVD media... in Player 4.6). Find the VIDEO_TS folder and open that. (The audio folder is for DVD-Audio disks.)
    http://docs.info.apple.com/article.html?artnum=93006

  • AE writing out using ffmpeg, possible?

    I'm wondering whether there are any clever methods to writing our ProRes 4444 files from after effects on the windows platform.
    There are several apps that wrap a UI around ffmpeg and its various prores compatible codecs
    I've seen a method using a frame server to push data to a waiting encoder but believe there's an 8bpc limit to that approach (it also seems a little unreliable)
    So is there a plug in for ffmpeg, or an approach that may allow me to directly write out prores movies files from AE without writing out and then encoding as a separate step?
    many thanks in advance
    paul

    Thanks Mylenium,
    A shame nevertheless
    cheers
    Paul

  • Step by step procedure on how to duplicate subtree on the target side

    I have a requirement where i have two types 'A' and 'B'. On the target side i have 6 fields out of which 2 have to repeat for type 'A' and remaining 4 for type 'B'. I have to sort my records such that all type 'A' records come above and all type 'B' come below that.
    I had written a UDF for that initially and even used sort by key. I got to know that i can duplicate subtree on the target side thus i can have one subtree for type 'A' and one for type 'B'.
    If i get 10 records which can either 'A' or 'B' randomly arranged, how should i go with Duplicate Subtree for that. Please explain with a scenario.

    Hi Jaya,
    You just right click your node which you want to duplicate then you can choose the option Duplicate subtree. Now you mapped with you source element A twice and simlarly you just duplicate another type for 4 times and map with source element B.
    Your problem will be solved.
    Best Regards,
    vijay

  • Access denied error while writing a file to the file system - myfileupload.saveas() throws system.unauthorizedexception

    hi,
    as part of my requirement , i have to perform read and  write  operations of  few files [ using the file upload control in my custom visual web part] and on submit button click.
    but while writing these files - with the help of  fileupload control - and when i use  myfileupload.saveas(mylocation);
    - i am saving these files into my D:\ drive of my server , where i am executing my code -, am getting access denied error.
    it throws system.unauthorizedexception.
    i have given full control on that folder where i was trying to store my attached files. and also  after following asp.net forums,
    i have added  iusr group added and performed all those steps such that, the file is saved in my D:\ drive.
    but unfortunately  that didnt happen.
    also
    a) i am trying the code with runwithelevatedprivileges(delegate() )  code
    b) shared the drive within the  d :drive where i want o save the files.
    c) given the full privieleges for the app pool identity- in my case , its
    network service.
    the  other strange thing is that, the same code works perfectly in  other machine, where the same sp, vs 2012  etc were installed .
    would like to know, any other changes/ steps i need to make it on this  server, where i am getting the  error.
    help is  appreciated!

    vishnuS1984 wrote:
    Hi Friends,
    I have gone through scores of examples and i am failing to understand the right thing to be done to copy a file from one directory to another. Here is my class...So let's see... C:\GetMe1 is a directory on your machine, right? And this is what you are doing with that directory:
    public static void copyFiles(File src, File dest) throws IOException
    // dest is a 'File' object but represents the C:\GetMe1 directory, right?
    fout = new FileOutputStream (dest);If it's a directory, where in your code are you appending the source file name to the path, before trying to open an output stream on it? You're not.
    BTW, this is awful:
    catch (IOException e)
    IOException wrapper = new IOException("copyFiles: Unable to copy file: " +
    src.getAbsolutePath() + "to" + dest.getAbsolutePath()+".");
    wrapper.initCause(e);
    wrapper.setStackTrace(e.getStackTrace());
    throw wrapper;
    }1) You're hiding the original IOException and replacing it with your own? For what good purpose?
    2) Even if you had a good reason to do that, this would be simpler and better:
    throw new IOException("your custom message goes here", e);
    rather than explicitly invokign initCause and setStackTrace. Yuck!

  • Hi Friends... I'm trying to delete a back-up file on mu TC but I get the message "The operation could not be completed because the item "bands" is in use. I'd like to start the Back from scratch, could help me out with deleting the current file?

    Hi Friends...
    I’m trying to delete a back-up file on mu TC but I get the message “The operation could not be completed because the item “bands” is in use. I’d like to start the Back from scratch, could help me out with deleting the current file?

    Sorry, I am very confused. I asked the following question....
    Is this the only backup file on your Mac, or do you have other backup files and data on the Time Capsule disk?
    The answer that you gave was....
    This is the only one
    Now you are saying that....
    But I have lots of other files on Time Capsule! The back up file is only one of them.
    Can you clarify, please?

  • I am trying to buy songs on itunes and half way through the terms and conditions come up, I accept them and press return and then I get a 'session timed out' notice and the sale hasn't gone through - tried loads of times / updating software, any answers?

    I am trying to buy songs on itunes and half way through the terms and conditions come up, I accept them and press return and then I get a 'session timed out' notice and the sale hasn't gone through - tried loads of times / updating software, any answers?

    I am trying to buy songs on itunes and half way through the terms and conditions come up, I accept them and press return and then I get a 'session timed out' notice and the sale hasn't gone through - tried loads of times / updating software, any answers?

Maybe you are looking for

  • Reporting by org hierarchy with drill down by each level of reports to...

    Hello, I'm trying to determine how to aggregate reporting by org hierarchy. Utlimately to report on opportunities at the highest level (CEO; all opportunities below CEO) then a second drill down report that shows summary by Level 2 (all those who rep

  • Working with remote application

    Hello everyone ! I installed the remote app on my iPad 2 to work with Apple TV3. And the application does not recognize the apple TV3. But the application detects the iTunes on my computer. What should I do to app detects the apple tv? Thank you very

  • Re-create controlfile when lost all datafile

    dear all, assume i have a database, i backuped full database use Rman, after that i deleted all of datafile,redolog file,controfile of database and i also deleted the backup controlfile by Rman, backup snapshot cotrolfile, so how to create the contro

  • Display is not visiable

    Hi My new nokia 925 is just 1 month old, and already I am having issues with it. Even though my phone is switched on, display is not up. I can hear calls coming in but can't see any thing. Dont know what to do?

  • Elements 6 and identifying faces

    Does anyone know if it is possible to be able to identify the face of several people on a photograph? I want to do this for my interest in family history. I would also have to identify the faces with a name. Many thanks.