PBDOM : Exporting to XML file gives a single line

I've been starting developing with PowerBuilder 12.5 a few weeks ago. I had to write some XML files, so I got familiar with the PBDOM library.
I can build a lot of different things, it's very nice, but one thing still bothers me :
In the output file, the whole XML is written on a single line.
I use the SaveDocument function.
For example, here is some code :
PBDOM_Document doc
PBDOM_Element noderoot, node1, node11, node12
doc = CREATE PBDOM_Document
doc.NewDocument("NodeRoot")
noderoot = doc.GetRootElement()
node1 = CREATE PBDOM_Element
node1.SetName("Node1")
noderoot.AddContent(node1)
node1.SetAttribute("Attr", "AttrValue")
node11 = CREATE PBDOM_Element
node11.SetName("Node11")
node11.AddContent("Here is a value")
node1.AddContent(node11)
node12 = CREATE PBDOM_ELEMENT
node12.SetName("Node12")
node12.AddContent("Here is another value")
node1.AddContent(node12)
doc.SaveDocument("myDoc.xml")
Here is the result when I open it with notepad++
<NodeRoot><Node1 Attr="AttrValue"><Node11>Here is a value</Node11><Node12>Here is another value</Node12></Node1></NodeRoot>
Whereas I wanted :
<NodeRoot> <Node1 Attr="AttrValue"> <Node11>Here is a value</Node11> <Node12>Here is another value</Node12> </Node1> </NodeRoot>
With the notepad++ XML tools plugin, I can use the "pretty print" function to get this nice representation. But I would like my file to be formatted this way from the beginning. I noticed that the "line ending" was set to UNIX format (indicator on bottom right of the window), but I'm working on Windows. When I use the menu to convert it to Windows format (CR+LF), it changes this indicator, but the code stays on one single line.
Is there a way to tell PBDOM to export the XML file with a nice output ?
Thank you !
Notes :
- Opening the XML file with Internet Explorer or Google Chrome gives me a nice vizualisation, with indentation, line breaks...
- Adding a <?xml version="1.0" encoding="ISO-8859-1" ?> does not help (I've been doing it while exporting some more complex files, but I still get the output on one line...)

Here is a very simple powerbuilder example. It uses MSXML instead of PBDOM. See my comments for hints how to use it with PBDOM.
oleobject lole_dom, lole_root, lole_element1, lole_element11, lole_element12
oleobject lole_Writer, lole_saxreader
string ls_result
// build DOM (you don't need this if you use PBDOM)
lole_dom = create oleobject
lole_dom.ConnectToNewObject ("Msxml2.DOMDocument")
lole_root = lole_dom.CreateElement ("NodeRoot")
lole_dom.documentElement = lole_root
lole_element1 = lole_dom.CreateElement("Node1")
lole_root.AppendChild(lole_element1)
lole_element1.SetAttribute("Attr", "AttrValue")
lole_element11 = lole_dom.CreateElement("Node11")
lole_element11.AppendChild (lole_dom.CreateTextNode("Here is a value"))
lole_element1.AppendChild(lole_element11)
lole_element12 = lole_dom.CreateElement("Node12")
lole_element12.AppendChild (lole_dom.CreateTextNode("Here is another value"))
lole_element1.AppendChild(lole_element12)
// this saves the DOM without formatting
//lole_dom.save ("d:\testxml.xml")
// this part is for formating
lole_Writer = create oleobject
lole_saxreader = create oleobject
lole_Writer.ConnectToNewObject ("MSXML2.MXXMLWriter")
lole_saxreader.ConnectToNewObject ("MSXML2.SAXXMLReader")
lole_Writer.omitXMLDeclaration = True
lole_Writer.indent = True
lole_saxreader.contentHandler = lole_Writer
// instead of DOM you can also put a XML string to parser: lole_saxreader.parse ("<node>...</node>")
// so you can also use the PBDOM output directly
lole_saxreader.parse (lole_dom)
// here is your formatted output
ls_Result = lole_Writer.output
MessageBox ("", ls_result)
lole_writer.Disconnectobject( )
lole_saxreader.Disconnectobject( )
lole_dom.Disconnectobject( )
DESTROY lole_writer
DESTROY lole_saxreader
DESTROY lole_dom

Similar Messages

  • Export large xml file in PL/SQL

    How to export large or big xml (XMLTYPE) into file system.
    I have tried with...
    1. UTL_FILE.PUT -- it has a limitation of 32767 chars
    2. DBMS_XSLPROCESSOR.CLOB2FILE supports little more than UTL_FILE but not in MB's
    i'm looking for options to export a xml file which is more than 5mb
    any suggestions?

    user12020576 wrote:
    I have tried with...
    1. UTL_FILE.PUT -- it has a limitation of 32767 chars
    It might have but this is not a problem, if you programmatically break it up in pieces.
    Have a look at https://forums.oracle.com/message/9748097#9748097
    The method demonstrates how to dump/write a CSV in binary format to disk.
    I used it to dump/write files way bigger than 10++ MB in size...

  • I have successfully exported subtitles (XML files) from FC version 7 to FC version 6, by choosing Apple XML Interchange Format Version 4. Now the exported subtitles suddenly read in one long line, at the top, not registering any "Enter" keystrokes.

    I have successfully exported subtitles (XML files) from FC version 7 to FC version 6, by choosing Apple XML Interchange Format Version 4. Now the exported subtitles suddenly read in one long line, at the top, not registering any "Enter" keystrokes. The same happens even if I re-import the XML file into Final Cut Version 7 (from where I exported the subtitles). Any tips on how to fix this?

    You might see if you can bring the xml file into Title Exchange Pro
    http://www.spherico.com/filmtools/TitleExchange/
    It's a great program and the author was very responsive when I had a problem.
    If it reads correctly, you can probably save it back out. 
    If you want to send it to me, I'll see if it opens.
    [email protected]

  • Can we Concatinate two XML files to a single output?

    I was stuck up with one scenario where I am getting a XML file output from a File Adapter say x1.
    And another XML file output say x2 from other adapter. Now I want to club this two XML files into a single output where it should contain the contents of x1 and x2
    When I am doing the Transformation I am getting the two files in the output folder but I want single file as output. Is it possible with ESB? If so Please suggest.
    --Chandra                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Chandra,
    Maybe the enrichment interaction scenario would work in your case.
    My colleague Lucas Jellema wrote a blog post on it: http://technology.amis.nl/blog/?p=1464.
    Or putting the same in a larger perspective: http://www.oracle.com/technology/pub/articles/jellema-esb.html.
    Hth,
    Sjoerd

  • What is the resource download URL in the exported books.xml file?

    What is the purpose of the resource download URL in the exported books.xml file? The following is an excerpt of a books.xml file.
      <resourceItemInfo>
        <resource>urn:uuid:309dffc8-7993-4837-b8e9-00easde241cfa</resource>
        <resourceItem>1</resourceItem>
        <metadata>
          <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">Paradise Lost</dc:title>
          <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">John Milton</dc:creator>
          <dc:format xmlns:dc="http://purl.org/dc/elements/1.1/">application/epub+zip</dc:format>
          <dc:publisher xmlns:dc="http://purl.org/dc/elements/1.1/">Project Gutenberg</dc:publisher>
          <dc:language xmlns:dc="http://purl.org/dc/elements/1.1/">en</dc:language>
          <dc:identifier xmlns:dc="http://purl.org/dc/elements/1.1/">http://www.gutenberg.org/ebooks/26</dc:identifier>
        </metadata>
        <src>http://xxxxx.com/books/309dffc8-7993-4837-b8e9-00e97e1cfa.epub</src>
        <downloadType>simple</downloadType>
        <licenseToken>
          <resource>urn:uuid:309dffc8-7993-4837-b8e9-00e97e241cfa</resource>
          <permissions>
            <display/>
            <excerpt/>
            <print/>
          </permissions>
        </licenseToken>
      </resourceItemInfo>

    No real purpose.

  • Can someone help me export a XML file from my project file?

    hey guys,
    I need someone to help me if possible, i was working at school with final cut pro and forgot to export it in xml format and only saved it in final cut pro format... i need to work on this at home and i have a pc.. because there are no lab hours and its due tommorrow, if anyone can help that would be great, thanks!!
    Winston

    i believe it was final cut pro 5, and i have premiere pro cs4 and it says itll read any xml file from final cut pro.
    if anyone wants to help me... here is my fcp file
    http://rapidshare.com/files/208267210/abstract.fcp.html
    you can just email me back the xml file to [email protected]
    i really appreciate it if someone can help me out!!
    Message was edited by: WinstonWong

  • How to export an XML file from oracle database?

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AM

    user3523292 wrote:
    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AMThis is a forum of volunteers. There is no "urgent" here. Nevertheless, a google search of 'xml oracle export' quickly lead me to this Oracle site:
    otn.oracle.com/sample_code/tech/xml/index.html
    I also see lots of hits when I search the documentation library at tahiti.oracle.com for 'xml'. This one in particular may be what you are looking for:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#ADXDK070

  • Export an XML file from oracle database

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database? is it possible..?
    thanks in advance,
    Bala. is it possible?
    Edited by: user3523292 on Nov 14, 2008 5:45 AM

    Here's the quick and dirty method using SQL*Plus...
    SQL> select * from emp where deptno = 10;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    SQL> set markup html on
    SQL&gt; select * from emp where deptno = 10;
    <br>
    <p>
    <table border='1' width='90%' align='center' summary='Script output'>
    <tr>
    <th scope="col">
    EMPNO
    </th>
    <th scope="col">
    ENAME
    </th>
    <th scope="col">
    JOB
    </th>
    <th scope="col">
    MGR
    </th>
    <th scope="col">
    HIREDATE
    </th>
    <th scope="col">
    SAL
    </th>
    <th scope="col">
    COMM
    </th>
    <th scope="col">
    DEPTNO
    </th>
    </tr>
    <tr>
    <td align="right">
          7782
    </td>
    <td>
    CLARK
    </td>
    <td>
    MANAGER
    </td>
    <td align="right">
          7839
    </td>
    <td>
    09-JUN-81
    </td>
    <td align="right">
          2450
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    <tr>
    <td align="right">
          7839
    </td>
    <td>
    KING
    </td>
    <td>
    PRESIDENT
    </td>
    <td align="right">
    </td>
    <td>
    17-NOV-81
    </td>
    <td align="right">
          5000
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    <tr>
    <td align="right">
          7934
    </td>
    <td>
    MILLER
    </td>
    <td>
    CLERK
    </td>
    <td align="right">
          7782
    </td>
    <td>
    23-JAN-82
    </td>
    <td align="right">
          1300
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    </table>
    <p>
    SQL&gt;which you can spool to a file.

  • Text Export vs XML file

    If I do Select All, and then Export and save as a .txt file, does the resulting file contain all the same key info as the iTunes library .xml file?
    Situation is, two users, me and Mrs. Helmet. All music stored in folder on dedicated media drive. However, I like death metal, Mrs. Helmet hates death metal. Mrs. Helmet does not want to see death metal in her library.
    Looked at library management software, but Mrs. Helmet does not want to master yet another software package. She's OK with Excel though... My library has everything in, so I did the Select All, and then Export and save as a .txt file bit, imported into Excel, deleted stuff from it as a test, then saved as a .txt file.
    I deleted her iTunes library, then imported the text file, and... new library containing just the test stuff.
    Before I do it for real, does anyone know if there are any serious problems with this approach?

    There's the rub.
    I am the most active music buyer. I'm adding anywhere between 50-100 songs a month. She does not know what I've added - hence the comment about folder watch. She will want some of it in her library, but not all.
    Assume that we were starting from scratch. Ideal solution would be to add everything to library, in some way tag unwanted stuff and automatically remove from library. As new folders/files are added, automatically added to library. If unwanted, could be tagged and automatically removed from library.
    That and the fact that we have desktop and laptop, and the laptop is often away from base, I was trying to find away to do smarter library management, including checking for missing links problem. I've not seen a library manager that quite does that. Could roll my own but not too au fait with xml, hence the desire to use .txt file if possible.

  • Export large XML-file

    Hi!
    I want to export XML-files, but when i select 50 rows of my object view i only get 43 in my utl_file.
    Here is the code:
    CREATE OR REPLACE PROCEDURE Export_XML_to_file_with_Schema IS
    qryCtx DBMS_XMLGEN.ctxHandle;
    result XMLTYPE;
    result_1 Clob;
    Abfrage VARCHAR2(4000);
    lob_length integer;
    read_amount integer;
    read_offset integer;
    buffer varchar2(100);
    loc varchar2(100) := 'usr_dir';
    f_hand utl_file.file_type;
    BEGIN
    -- Setting up offset and no. of chars to be read in
    -- in one go from clob datatype.
    read_offset := 1;
    read_amount := 75;
    --Opening file
    f_hand := Utl_File.Fopen(location =>'d:\oracle\utl_file\',
    filename =>'test.xml',
    open_mode =>'w',
    max_linesize => 32767);
    Abfrage :='Select * from I_GESAMT_V where rownum < 50';
    qryctx := dbms_xmlgen.newContext(Abfrage);
    Returns a new context
    PARAMETERS: queryString (IN)- the query string, the result of which needs to be converted to XML
    RETURNS: Context handle.
    Call this function first to obtain a handle that you can use in the getXML()
    and other functions to get the XML back from the result.
    dbms_xmlgen.setRowSetTag(qryCtx,NULL);
    rowsetTag (IN) -
    the name of the document element.
    NULL indicates that you do not want
    the ROW element to be present.
    Call this to set the name of the document root element,
    if you do not want the default "ROWSET" name in the output.
    You can also set this to NULL to suppress the printing of this element.
    However, this is an error if both the row and the rowset are null and there
    is more than one column or row in the output.
    dbms_xmlgen.setRowTag(qryCtx,'INSP_PDA');
    rowTag (IN) -
    the name of the ROW element.
    NULL indicates that you do not want the ROW element to be present.
    Call this function to set the name of the ROW element,
    if you do not want the default "ROW" name to show up.
    You can also set this to NULL to suppress the ROW element itself.
    Its an error if both the row and the rowset are null and there
    is more than one column or row in the output.
    -- now get the result
    result := DBMS_XMLGEN.getXMLType(qryCtx);
    select xmlelement("INSOBJ",
    xmlattributes('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",'http://sv6:8080/sys/schemas/SCOTT/sv6:8080/public/mydocs/inspection_pda_schema.xsd' AS "xsi:noNamespaceSchemaLocation"), result) into result from dual;
    result_1 :=result.getClobval();
    -- Getting the length of the data stored in Clob
    lob_length := dbms_lob.getlength(result_1);
    utl_file.put(f_hand,'<?xml version="1.0" encoding="windows-1252"?>');
    Utl_File.New_Line (f_hand,1);
    -- Reading data from clob variable and writng into file.
    while (lob_length > 0) loop
    dbms_lob.read(result_1,read_amount,read_offset,buffer);
    utl_file.put(f_hand,buffer);
    read_offset := read_offset+read_amount;
    lob_length := lob_length-read_amount;
    if lob_length < read_amount then
    read_amount := lob_length;
    end if;
    end loop;
    utl_file.fclose(f_hand);
    END Export_XML_to_file_with_Schema ;
    Is there something wrong with my code?
    Thanks for help.
    With best regards
    Nicole

    HI!
    I've seen that the utl_file max_linesize is the problem, is there an alternative except 'Spool'!
    Thanks for help.
    With best regards
    Nicole

  • Export/import xml files

    hey,
    I've been trying to import a xml file that was originally created in CP6 but has been upgraded to a captivate8 project and when I try to import the xml file again it doesn't work, why is that?

    OK. I'm not following you. 
    First you said the XML file was created in Cp6 and now you say it was exported from Cp8.
    So which is it?

  • When exporting XML files, I get forced line breaks before and after my xmltag

    hi everybody,
    as I said, i do a javascritp that exports xml files. First I clean up my text by removing every invisible characters with app.findpreferences. Nevertheless, my xml files is almost well formed beacause i got before and after each xmltag a forced line break. Somebody could explain to me why ?
    I don't use prettyIndent and prettyPrinting .
    Best regards
    Américo Pinto

    hi everybody,
    as I said, i do a javascritp that exports xml files. First I clean up my text by removing every invisible characters with app.findpreferences. Nevertheless, my xml files is almost well formed beacause i got before and after each xmltag a forced line break. Somebody could explain to me why ?
    I don't use prettyIndent and prettyPrinting .
    Best regards
    Américo Pinto

  • Export into XML file

    Hi Community,
    via the SDK it is possible to create XML File input routines for XML files from WebDAV.
    We need a similar technique for outbound XML File output.
    What possibilities do we have? Are there similar ways for XML output?
    Thanks
    Thomas

    There are no similar ways. Your question is more towards creating XML files from Cloud product with the help of studio.
    You can take help of attachment folder. You can create files. Couple of things you have to keep in mind.
    New line representation :: "\r\n"
    Makes sure that you have .xml extension for your file name which you are gonna attach.
    File content has to be populated by your absl code. I've worked on something similar earlier. So, I can say this is possible but you have be careful that you should not miss file format standards.
    FileContent datatype inside AttachmentFolder has no restrictions in size.

  • How to pass an xml file as a command line argument

    hi,
    i would like to know how to pass xml tags (not an xml file) while running java command. i have already compiled the code and i have a .class file generated. i need to pass this argument in the java command because i am calling a web service which requires an xml as parameter to it.
    to be precise the java code contains soap request and i need to pass xml at run time.
    pl do reply if you have any ideas or solutions...
    Thanks in advance,
    gnsinhyd

    I got the answer myself
    Got the answer myself. I needed the ActionServlet Context in the ActionClass. This is what I have done...
    It works.
    LogonAction.class
    Code:
    InputStream is = getServlet().getServletContext().getResourceAsStream("/WEB-INF/conf/menu.xml");
    XMLMenuBuilder.java
    Code:
    Document document = builder.parse(is);
    Thanks

  • Why is my entire XML file all on one line?

    I am createing a XML file using DOM. The file is started as a new document and I add child nodes using the appendChild() function. I am also using the transformer class to write the file. The file output is as follows:
    <?xml version="1.0" encoding="UTF-8"?><TestSystems><department>Tape<program>T10000A</program></department></TestSystems>
    and I want it to be:
    <?xml version="1.0" encoding="UTF-8"?>
    <TestSystems>
    <department>Tape
    <program>T10000A</program>
    </department>
    </TestSystems>
    How can I get a nicely formated file?
    Here is my code:
    import java.io.*;
    import javax.xml.parsers.*;
    import javax.xml.xpath.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.dom.DOMSource;
    public class XMLTestClass {
        DocumentBuilderFactory domFactory;
        DocumentBuilder domBuilder;
        Document xmlDoc;
        String xmlFile = "c:\\test.xml";
        /** Creates a new instance of XMLTestClass */
        public XMLTestClass() {
            try{
                domFactory = DocumentBuilderFactory.newInstance();
                domBuilder = domFactory.newDocumentBuilder();
                //xmlDoc = domBuilder.parse(new File(xmlFile));
            //    xpath = XPathFactory.newInstance().newXPath();
            }//try
            catch (ParserConfigurationException e) {
                System.err.println("ParserConfigurationException caught...");
                e.printStackTrace();
        public void run(){
            System.out.println("Test");
            xmlDoc = domBuilder.newDocument();
            Element rootElement = xmlDoc.createElement("TestSystems");
            xmlDoc.appendChild(rootElement);
            Element deptElement = xmlDoc.createElement("department");
            deptElement.appendChild(xmlDoc.createTextNode("Tape"));
            rootElement.appendChild(deptElement);
            Element progElement = xmlDoc.createElement("program");
            progElement.appendChild(xmlDoc.createTextNode("T10000A"));      
            deptElement.appendChild(progElement);   
            try{
                TransformerFactory tf = TransformerFactory.newInstance();
                Transformer transform = tf.newTransformer();
                Source src = new DOMSource(xmlDoc);
                Result dest = new StreamResult(new File(xmlFile));
                transform.transform(src, dest);
            catch(Exception exp){}
        public static void main(String[] args){
            XMLTestClass xml = new XMLTestClass();
            xml.run();
    }

    Thanks for the tip. The code sort of works now but the funny thing is that the file output does not indent, but is no longer on one line. The out put is now (no indents):
    <?xml version="1.0" encoding="UTF-8"?>
    <TestSystems>
    <department>Tape<program>T10000A</program>
    </department>
    </TestSystems>
    Also the line
    transform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    [\code]
    does not seem to have any affect.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Making Read Only A select List Item

    Hi, I am using Application Express 3.1.1.00.09 version. If the date field is future date then the Select List field should become Read only. I tried to make "read only". When I made it "read only" '>[] is displayed??? Does some one have a solution? T

  • Error in EPM System (EPM 11.1.2)

    Hi, On accessing the http://<Server IP>:19000/awb/ URL, I found the below error messages: 1. Loading the module 'awb.appcontainer' failed 2. Error Loading Adf 'http://<Server IP>:19000/awb/modules/com/hyperion/awb/web/appcontainer/Adf.do?instance=2'

  • Guidelines on Hardware requirements for PeopleSoft 9.2 / 8.53

    Hi- Customer is looking for a realistic numbers or guide lines or sample sizes which can be used as a basis for hardware requirements estimation. Details like Total IOPS requirements for system no of SQL transaction issued per min by light, medium an

  • Relocating and moving my Mac

    Hi Everyone, I'm about to relocate to another state and plan on sending my G4 by Fed Ex - Do I need to prepare my Mac for the journey other than placing it back into it's original mailed to me box/container? I may also change my move plans for my Mac

  • INITIALIZATION event of Tabstrips in Selection screens

    Hello all. I created a selection screen with 6 tabs. Each tab is a "standalone" transaction with it's own logic (i.e. tab1 will execute form 1, tab2 will execute form 2 and so on). In the end each tab will display an ALV report. The problem: after th