Writing XML object in a file

Hi, I use InDesign JavaScript to make an XML object in memory. When my script's done, I want to write the XML to a file. When I run the code below, the file is created, but XML is not written to the file. Any help would be appreciated. Thank you. Rick

#target indesign

var partsMap = <partsMap />;
savePartsMap (partsMap);

function savePartsMap (partsMap) {
    
    var partsFile;
    
    // Make a File object for the parts map XML file.
    partsFile = new File("E:\\Test.xml");
    // Open the map file.
    partsFile.open("w");
    partsFile.write(partsMap);
    partsFile.close();
}

Add partsFile.encoding = 'UTF-8'; right after the instantiation of your file.

I don't know, but you can also write partsMap.toXMLString() instead of the partsMap.toString() you write implicitly.

Jeff

Tags: InDesign

Similar Questions

  • How to write the xml data to a file

    Hi all

    We have a requirement of writing, the xml data in a file in the data directory in the server. Generate xml data using the SQL below.

    SELECT XMLELEMENT ("LINE",
    XMLELEMENT ('CELL', xmlattributes (LIKE 'column name', ' EBIZCZMDL_01'), inventory_item_id).
    XMLELEMENT ('CELL', xmlattributes (AS 'Name of COLUMN', ' EBIZFFMT_01'), attribute29).
    XMLELEMENT ('CELL', xmlattributes ("COMMON" AS "Name of COLUMN"), inventory_item_id |) '' || attribute29 | "ITM")
    "XMLDATA" AS "PRODUCE")
    OF apps.mtl_system_items_b

    When we try to write this query data in a file using UTL_FILE.put_line, the script gives error
    PLS-00306: wrong number or types of arguments in the call to "PUT_LINE '.

    If anyone can help pls...

    Thanks in advance

    The call to dbms_xslprocessor.clob2file is in the cursor for the specific SQL loop.

    This is obviously the problem.
    The file is replaced with each iteration.

    Do not use a cursor at all.

    See the example below, it should be close to your needs:

    DECLARE
    
       l_file_name      VARCHAR2 (30);
       l_file_path      VARCHAR2 (200);
    
       l_xmldoc         CLOB;
    
    BEGIN
    
       l_file_path := '/usr/tmp';
       l_file_name := 'TEST_XREF4.xml';
    
       SELECT XMLElement("xref", xmlattributes('http://xmlns.oracle.com/xref' as "xmlns"),
                XMLElement("table",
                  XMLElement("columns",
                    XMLElement("column", xmlattributes('EBIZFFMT_01' as "name"))
                  , XMLElement("column", xmlattributes('COMMON' as "name"))
                  , XMLElement("column", xmlattributes('EBIZQOT_01' as "name"))
                  , XMLElement("column", xmlattributes('EBIZCZMDL_01' as "name"))
                  , XMLElement("column", xmlattributes('EBIZCZGOLD_01' as "name"))
                  ),
                  XMLElement("rows",
                    XMLAgg(
                      XMLElement("row",
                        XMLElement("cell", xmlattributes('EBIZCZMDL_01' AS "colName"), inventory_item_id)
                      , XMLElement("cell", xmlattributes('EBIZFFMT_01' AS "colName"), attribute29)
                      , XMLElement("cell", xmlattributes('COMMON' AS "colName"), inventory_item_id || '' || attribute29 || 'ITM')
                      )
                    )
                  )
                )
              ).getClobVal()
       INTO l_xmldoc
       FROM apps.mtl_system_items_b
       WHERE attribute29 IS NOT NULL
       ;
    
       dbms_xslprocessor.clob2file(l_xmldoc, l_file_path, l_file_name, nls_charset_id('UTF8'));
    
    END;
    /
    

    BTW, the directory in DBMS_XSLPROCESSOR parameter. CLOB2FILE must be an Oracle Directory object, not a literal path.

  • Adding data to XML objects.

    Hello

    I wonder how to add completely new data to the XML data that I hang in a var.

    I am importing XML data in an editor that I've created.  The XML looks like this:

    < itemList_120 >

    < mediaFile order = '1' playTime = '2 ' transIn = transOut '1' = ' 9' > gif.gif < / mediaFile >
    < order = '2' playTime '1' = transIn mediaFile transOut = '6' = "8" > jpg.jpg < / mediaFile >

    < / itemList_120 >

    The code that I put in place to contain the XML data is as follows:

    var theXML:XML;
    var myXML:XMLList;

    function called when the xml file loading is complete
    function onXMLLoaded_120 (e: Event): void {}

    a new instance of the xml object
    Check = new XML (e.target.data);

    Use the object XMLList to children nodes filter thumbnails
    myXML = theXML.itemList_120;

    etc - and it works for importing the XML file - if I trace (myXML), XML data above are displayed.

    I find that you can change the different parts of the XML data in myXML in this way:

    myXML.mediaFile[1].@playTime = 2

    (which changes the second line of XML code for this: < mediaFile order = "2" "2" = transIn playTime transOut = '6' = "8" > jpg.jpg < / mediaFile >)


    My question is:

    Rather than change the existing XML data, how to add completely new data?  That is to say, if the var above who held two lines "mediaFile" of XML, how to add or insert a third?

    Thanks for taking a peek at this.

    Shaun

    check the xml class.  There are all the methods you need to add, insert, and delete nodes, attributes, etc.

  • Pass data from one XML object to an itemRenderer

    I'm trying to color the background of a column in a datagrid, and we found a sample file that illustrate the concept. However, the sample has data stored in an arrayCollection collection, while mine is in an XML object. The problem is that the data from the sample file apparently automatically passed to the itemRenderer (below: notice the trace statement). My XML object does not automatically pass to the itemRenderer data. So my questions are:

    1. is there a simple way to pass data stored in an XML object to an itemRenderer

    or

    2 should I convert my XML an arrayCollection collection? If Yes, what is the best way to do it - I tried the following, but without success:

    < mx: Model id = source = "example3.xml" / "xmldata" >
    < mx:ArrayCollection id = "myAC" source = "{ArrayUtil.toArray (xmldata. Example1)}"/ >

    Here is what the XML looks like:

    < TABLE >
    example < 1 >
    < Difficulty > 0,5 < / difficulty >
    < discrimination > 0.7 < / discrimination >
    < item 3 > < / point >
    < / example1 >
    < /table >

    Here is the itemRenderer:

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Label ' http://www.Adobe.com/2006/MXML ">

    <!--
    This element converter simply extends label and overrides the updateDisplayList function
    draw a filled rectangle of gradient. The colors of the gradient are determined from the
    data.
    ->
    < mx:Script >
    <! [CDATA]

    to import flash.geom.Matrix;
    import flash.display.GradientType;
    import flash.display.Graphics;

    override the updateDisplayList(unscaledWidth:Number,_unscaledHeight:Number):void function
    {
    super.updateDisplayList (unscaledWidth, unscaledHeight);

    var m:Matrix new matrix());
    m.createGradientBox (unscaledWidth, unscaledHeight);

    var Graphics = g:Graphics;
    trace("Data.COL3="+Data.col3)
    var colors: Array = (data.col3 < 2000? ([0x0000CC, 0x0000FF]: [0x00CC00, 0x00FF00]);

    g.Clear ();
    g.beginGradientFill (GradientType.LINEAR, colors, [0.2,0.6], [0,255], m);

    the rectangle is drawn a little high and a bit large to compensate for the gap
    the DataGrid control is introduced between the rows.
    g.drawRect (0, -2, unscaledWidth, unscaledHeight + 4);
    g.endFill ();
    }
    []] >
    < / mx:Script >
    < / mx:Label >

    This code example should answer your question of how to import data in the renderer automatically. It is through the dataProvider of the DataGrid and then refer to it in the renderer in the form of data. XYZ, where XYZ is the field in the XML file with the data. See FB 3 help sys on the e4x syntax.

    -mainapp.mxml-

    
    
      
        
      
      
      
        
          
          
          
        
      
    
    

    -MyLabel.mxml-

    
    
      
        
      
    
    

    -data2.xml-

    
    
           0.5 
           0.7 
           3 
       
  • Writing xml config with AIR

    Greetings!

    I know that this is possible. I can't think of a way to do that is very smooth, however. For the application, the user will enter data that will be stored in a config file to another Java application that is waiting for the file to be created (both on the same machine with air). Can someone tell me a simple example?

    The config itself is big enough and I'll probably use several viewstats to get all the information. Any help or advice are appricated!

    Build your user interface XML object and then write with the AIR API file wrigin.

  • Change "current node" of the XML object

    Hello

    I am trying to edit the "current node" of an XML object, but I still don't know what will be the current node.

    My XML object to load an external XML file:

    < mx:XML id = source="assets/article_text.xml"/ "featureData" >

    and I read that data through a < mx:Repeater > create a < mx:TextArea > for each 'currentItem '.

    < mx:Repeater id = dataProvider = "{featureData.body_text.children ('repeatParas')}" >
    "< mx:TextArea htmlText =" {repeatParas.currentItem} "width ="80% "borderStyle ="none"click =" showBodyEditor (event, event.currentTarget.getRepeaterItem ()) "verticalScrollPolicy =" off "creationComplete ="resizeTextArea (event); "updateComplete ="resizeTextArea (event); "/ > < / mx:Repeater >

    A click on < mx:TextArea > event load a pop-up window containing a RichTextEditor that contains the content of currentItem:

    private void showBodyEditor(event:Event,_item:String):void {}
    var pop1:BodyEditor = BodyEditor (PopUpManager.createPopUp (this, BodyEditor, true));
    Set the properties of the custom component BodyEditor.
    POP1.showCloseButton = true;
    POP1.targetBodyText = event.currentTarget;
    POP1. CurrentNode = item;
    PopUpManager.centerPopUp (pop1);
    }

    I then passes the value of everything that has been entered in the return to the initial < mx:TextArea > RichTextEdior via a function on a button click event '' made '' (processBodyText()):

    [Bindable]
    public var targetBodyText:Object;
    [Bindable]
    public var currentNode:String;

    Transfer data to text boxes
    private function processBodyText (): void {}
    targetBodyText.htmlText = String (bodyTextForm.htmlText);
    currentNode = String (bodyTextForm.htmlText);
    Remove pop-up.
    PopUpManager.removePopUp (this);
    }

    But what I can't do is actually updated for that node in the featureData XML object without explicitly saying what node to update (for example, it works: parentApplication.featureData.body_text.p [1] = String (bodyTextForm.htmlText);) I don't necessarily know which node to update, I just want to be able to update some node I happen to be editing at the time.

    Is this possible?

    Thanks to anyone who can enlighten us!

    I'll reply to my own post (where everyone was watching).

    I just changed the parameters/variables currentNode type Object (instead of string) and within the processBodyText function, I replaced

    currentNode = String (bodyTextForm.htmlText);

    with

    currentNode.setChildren (bodyTextForm.htmlText);

    who updates the node in the XML data provider.

    I still need to get rid of some of the gobblygook of html that is passed to the rear (for example < TEXTFORMAT LEADING '2' = >) but as long as I am able to update the current node, I'm happy (for now).

  • Writing data in the CSV file?

    I tried, but in vain, to write data in the CSV file, with the column headers of the file labeled appropriately to each channel as we do in LabView (see attached CSV).  I know that developers should do this same in .net.  Can anyone provide a snippet of code to help me get started?  In addition, maybe there is a completely different way to do the same thing instead of writing directly to the CSV file?  (In fact, I really need to fill a table with data and who join the CSV every seconds of couple).  I have the tables already coded for each channel, but I'm still stuck on how to get it in the CSV file.  I'm coding in VB.net using Visual Studio 2012, Measurement Studio 2013 Standard.  Any help would be greatly appreciated.  Thank you.

    a csv file is nothing more than a text file

    There are many examples on how to write a text using .NET file

  • Temporary Internet of objects/Downloaded Program Files

    The temporary Internet items/Downloaded Program files: delete Internet Temp files/cookies but never the objects/program Temp files regularly. The reason is that the "last date of access: ' is still showing the day I visit the. I was under the impression that they were originally uploaded to the Temp file before be downloaded on a disk, IE C. If so, can they be removed? I didn't want to do it if it meant it would interfere with the operation on the day the day of my PC/access some programs. Program files consist of programs such as JavaRuntimeEnvironment, ParallelGraphics Cortona, MessengerStatsClient, ShockwaveActiveX and others. Most say "installed" and a date of creation, but some say "damaged". My apologies if this question is fundamental, but appreciate any thoughts on this issue. Thank you - Keith-Shenstone

    Hi Keith,

    · What you are referring when you say "but some say"damaged "?

    · Where exactly do you see that?

    Downloaded program files are ActiveX controls and Java programs that are automatically downloaded from the Internet when you view certain pages. These files are temporarily stored in the Downloaded Program Files folder on the hard disk.

    The "Downloaded program files" folder contains a feature that allows you to easily uninstall ActiveX controls. When this folder is deleted, a new "Downloaded Program Files" folder is created the next time Internet Explorer to download new program files. However, the newly created folder does not contain the functionality to easily uninstall ActiveX controls.

    The controls that have been deleted by the original folder are listed with the damaged state. These controls must be removed because the associated files have already been deleted.

    You can use built in Disk Cleanup tool in windows that allows you to delete unnecessary files from your hard drive.

    See the link below: how to automate the disk cleanup tool in Windows XP:http://support.microsoft.com/kb/315246

    With regard to:

    Samhrutha G S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to convert XML into a PDF file?

    I use Adobe Acrobat X Pro 10.0.  I saved a PDF file in an XML 1.0 document.  I would like to be able to send this XML document and have the recipient opened the XML into a PDF file.  Does anyone know how to do this?

    Thank you

    Hello hilaryb49990629,

    Thanks much for posting on the Adobe forums.

    I'm sorry, but XML is not a type of file Adobe Acrobat/Reader can open. It can be opened in a browser or Editor (such as Notepad) to view its content.

    Kind regards

    Ana Maria

  • How to export all objects in ddl file.

    Hello

    How to export all objects in ddl file.

    Hello

    You can try this thing, but you need to do some R & D on your side as well.

    Reel under query on your hard drive.
    Run below command then you will get the instructions to get the ddl for the whole table.

    select 'select dbms_metadata.get_ddl(TABLE,'||tname||') FROM DUAL;' FROM TAB;
    

    It will show the result as for all tables...:

    select dbms_metadata.get_ddl(TABLE,NEW) FROM DUAL;
    

    Now you open the hold file in Notepad and make the above statement as:

    select dbms_metadata.get_ddl('TABLE','NEW') FROM DUAL;
    

    You can press on in Notepad ctrl and H to replace key and type in the first box of text TABLE and in the second "TABLE."
    Ditto for the name of the table.

    The slide in one by one by coil settting on so you will get each ddl statement in different files.

    I don't know if you are interested in R & D to yours and if you aren't then we forget.

  • Problem loading xml using sql loader file

    I am trying to load data into the table test_xml (xmldata XMLType)

    I have an xml file and I want any file to load in a single column

    When I use the following control file and run from the command-line as follows
    sqlldr $1@$TWO_TASK direct control=$XXTOP/bin/LOAD_XML.ctl = true; :

    DOWNLOAD THE DATA
    INFILE *.
    TRUNCATE INTO TABLE test_xml
    XmlType (XMLDATA)
    FIELDS
    (
    tank fill ext_fname (100),
    XMLDATA LOBFILE (ext_fname) COMPLETED BY expressions of folklore
    )
    START DATA
    U01/appl/apps/apps_st/appl/XXTop/12.0.0/bin/file. XML

    the file is loaded in the table perfectly.

    Unfortunately I can't hard-code the name of file as file name will be changed dynamically.

    so I removed the block

    START DATA
    U01/appl/apps/apps_st/appl/XXTop/12.0.0/bin/file. XML

    control file and tried to run by giving the following command line path

    sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl direct data=/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml = true;

    But strangely it attempts to load each line of the xml file in the table instead of the whole file

    Please find the log of the program with the error

    ------------------------------------------------------------------
    Loading XML through SQL * Loader begins
    ------------------------------------------------------------------
    SQL * Loader-502: cannot open the data file ' <? XML version = "1.0"? > ' table field TEST_XML XMLDATA
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file '< root >' XMLDATA field table TEST_XML
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file '< ScriptFileType >' field XMLDATA table TEST_XML
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file ' < Type > forms < / Type > ' table field TEST_XML XMLDATA
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file ' < / ScriptFileType > ' table field TEST_XML XMLDATA
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file '< ScriptFileType >' field XMLDATA table TEST_XML
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file ' < Type > PLL < / Type > ' table field TEST_XML XMLDATA
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file ' < / ScriptFileType > ' table field TEST_XML XMLDATA
    SQL * Loader-553: file not found
    SQL * Loader-509: System error: no such file or directory
    SQL * Loader-502: cannot open the data file '< ScriptFileType >' field XMLDATA table TEST_XML

    Please help me how can I load full xml in a single column using command line without Hardcoding in the control file

    Published by: 907010 on January 10, 2012 02:24

    But strangely it attempts to load each line of the xml file in the table instead of the whole file

    Nothing strange, that the data parameter specifies the file containing the data to load.
    If you use the name of the XML here, the control file will try to interpret each line of XML as being separate ways.

    The traditional approach this is to have the name of the file stored in another file, say filelist.txt and use, for example:

    echo "/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml" > filelist.txt
    sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl data=filelist.txt direct=true;
    
  • How to remove a child in an XML object?

    Hey guys, I'm a new user for AS3. I did an xml object and add a few children. I use appendChild() to add a child to the XML. But if I want to delete one, what should I do? I tried to search in the reference, but I can not find a remove function.

    var questions: XML =

        
        
        
        
        
        

    ;

    function deleteNode(value:XML)
    {

    if(value==null) {return ;}
    If (value. Parent () == null) {return ;}
    delete value.parent () .children () [value.childIndex ()]
    }

    Example: To remove the third node (Id = 3)

    deleteNode (questions. Issue. (@Id is "3") [0])

    OR

    deleteNode (questions. Question [2])

  • How to use variables to populate XML objects

    Hello

    I'm trying to fill an XML object with information from a loop for. It seems that the info will as long as the string information. Thoughts?

                   for(var i:int=0; i<dataSource.length; i++){
                        
                        xmlList += <item></item>;
                        
                        for(var s:String in dataSource[i]){
                             xmlList[i].item +=   <s>test info</s>;
                                                 //<hobby>soccer</hobby>;
                                                 
                             trace(s);
    
                        
                        }
    

    This is a generic example of what I think you want to do:

    var dataSource:Array =
    [
    {name: "One", value: 1 "},
    {name: "two", value: 2 "},
    {name: "three", value: 3 "}
    ]
    var xmlList = new XMLList();
    for (var i: int = 0; i
    var node: XML = ;
    for (var s:String in dataSource [i])
    {
    var propNode:XML = <{s}> ;
    propNode.appendChild (dataSource [i] [s]);
    node.appendChild (propNode)
    }
    xmlList += node;

    }
    trace (xmlList)

  • To access the elements of the XML object

    A web service is back from the data to me as an XML object. I can access the items in the XML like this:

    & lt; cfset username = #XMLDocument.login.username # & gt; and if I have this dump to screen with cfoutput I get just the user name. But if I try to user the variable username as an attribute within a url cflocation it appears in the attributes with the xml notation, for example in the attributes will be:

    username = & amp; Lt;? XML = 20version & amp %; quot; 1.0 & amp; quot; % 20encoding = & amp; quot; UTF-8 & amp; quo t;? & amp; GT;

    Any help much appreciated. Thank you

    > Username>

    > I can't access like this:
    > #XMLDocument.login.username # this will show all
    > 'User_name '.

    Are you sure? If you view the source, don't you get the whole node?

    > but if I send these details as attributes, as follows:<>
    > url = ' index.cfm? username = #XMLDocument.login.username #... Can I get xml
    > formatting instead of just the user name.

    Well Yes.

    #XMLDocument.login.username # designates the entire node, not just the
    xmlText bit between the tags as you seem to expect. You want to
    just the xmlText node.

    You should probably read the docs on how CF manages XML:
    http://livedocs.Adobe.com/ColdFusion/8/htmldocs/help.HTML?content=XML_02.html.

    --
    Adam

  • Issue when writing xml file

    Guys,

    I read the data in table and writing to XML file and see the following error when it reached create table step.

    ODI-1228: LOAD_DATA_COMM (export) failed on target connection XML COMM_POS.

    Caused by: java.sql.SQLException: unexpected token: C$ _COMMDAILY required:)

    at org.hsqldb.jdbc.Util.sqlException (unknown Source)

    for org.hsqldb.jdbc.JDBCPreparedStatement. < init >(Unknown Source)

    at org.hsqldb.jdbc.JDBCConnection.prepareStatement (unknown Source)

    at com.sunopsis.jdbc.driver.xml.SnpsXmlConnection.prepareStatement(SnpsXmlConnection.java:1177)

    at sun.reflect.GeneratedMethodAccessor65.invoke (unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    to oracle.odi.core.datasource.dwgobject.support.OnConnectOnDisconnectDataSourceAdapter$ OnDisconnectCommandExecutionHandler.invoke (OnConnectOnDisconnectDataSourceAdapter.java:200)

    to $Proxy2.prepareStatement (Unknown Source)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.doInitializeStatement(SQLCommand.java:83)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:117)

    The pointers will be appreciated!

    Thank you

    The problem solved by mentioning the name of correct schema in the physical schema.

Maybe you are looking for