Sending variable value from php to flash to load an xml file

I would like to load an XML file from the location locally or on the server being unaware of the name of the file. I am using PHP for sending the filename to Flash.
The below is the PHP code:
<?php
filesInDir('C:\Documents and Settings\457305\My Documents\shrikant\Flash Tutorials\webassist');
function filesInDir($tdir)
        $dirs = scandir($tdir);
        foreach($dirs as $file)
                if (($file == '.')||($file == '..'))
                elseif (is_dir($tdir.'/'.$file))
                        filesInDir($tdir.'/'.$file);
                else
                        echo "fileName=$file";
?>
And below is the loading Actionscript code:
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.net.URLVariables;
stop();
// Define the PHP file to be loaded
var phpFile:String = "http://localhost/webassist/test.php";
var cons_xml:XML;
var xmlLoader:URLLoader = new URLLoader();
// Specify dataFormat property of the URLLoader to be "VARIABLES"
// This ensures variables loaded into Flash with same variable names
xmlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
xmlLoader.load(new URLRequest(phpFile));
xmlLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(evt:Event):void
          trace(evt.target.data.fileName);
          //cons_xml = new XML(evt.target.data.fileName);
          //gotoAndPlay(2);
When I trace the evt.target.data it displays "fileName=mainOpenEndedXML%2Exml" and when I trace evt.target.data.fileName the fileName is properly displayed as "mainOpenEndedXML.xml".
But in the next two lines where the loading occurs it does not load the file i.e the swf file from xml doesn't play.
I have been searching the Internet for answers but not able to find any solutions.
The loading works properly if i directly insert the xml file in the code and the swf's in the XML file play propertly. The below is the code for the same:
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.net.URLVariables;
stop();
var cons_xml:XML;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("mainOpenEndedXML.xml"));
xmlLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(evt:Event):void
          cons_xml = new XML(evt.target.data);
          gotoAndPlay(2);
Any help on this would be greatly appreciated

Yes. you already said that, but I guess you don't understand what I said.  You are loading the PHP fle to get the filename, but nowhere are you taking that filename and loading the file that was named. 
You need to do two loading operations.  The first one to get the filename, and the second to load the file with that name.  Maybe if you name the PHP file loader phpLoader instead of xmlLoader it will start to make more sense to you.  Something like the following...
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.net.URLVariables;
stop();
// Define the PHP file to be loaded
var phpFile:String = "http://localhost/webassist/test.php";
var phpLoader:URLLoader = new URLLoader();
// Specify dataFormat property of the URLLoader to be "VARIABLES"
// This ensures variables loaded into Flash with same variable names
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.load(new URLRequest(phpFile));
phpLoader.addEventListener(Event.COMPLETE, processPHP);
function processPHP(evt:Event):void
         var xmlLoader:URLLoader = new URLLoader();
         xmlLoader.load(new URLRequest(String(evt.target.data.fileName)));
         xmlLoader.addEventListener(Event.COMPLETE, processXML);
var cons_xml:XML;
function processXML(evt:Event):void
          cons_xml = new XML(evt.target.data);
          gotoAndPlay(2);

Similar Messages

  • Special characters in String variable sent from php.

    Hello. Assuming that I send some String variable from php into flash:
    AS3:
    var MyImportedString:String;
    var variables_page_text:URLVariables = new URLVariables();
    var varSend_page_text:URLRequest = new URLRequest("MyPHP.php");
    varSend_page_text.method = URLRequestMethod.POST;
    varSend_page_text.data = variables_page_text;
    var varLoader_page_text:URLLoader = new URLLoader;
    varLoader_page_text.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader_page_text.addEventListener(Event.COMPLETE, var_comp_page_text);
    varLoader_page_text.load(varSend_page_text);
    function var_comp_page_text(event:Event):void {
        MyImportedString =  event.target.data.MyVariable;
    php:
    <?php
    header('Content-Type: text/html; charset=utf-8');
    $MyString = "some tekst &";
    print "MyVariable=" . $MyString;
    ?>
       I've noticed that the special character '&' residing inside String, throws an error:  #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
      My first thought was, it has something to do with html entities, but other entities (like <> or ") don't throw any error. Besides, the use of php functions like htmlentities(); or html_entity_decode(); doesn't make any difference in this case:
    print "MyVariable=" . htmlentities($MyString);
    or
    print "MyVariable=" . html_entity_decode($MyString);
      I've also noticed that characters like '%', '^', '+' don't show up at all;
      What does it mean? Any ideas?
      Reagards.

    Thank You 'moccamaximum'.
    Ok. So here is the solution (php function posted by 'moccamaximum' does the trick):
    AS3:
    var MyImportedString:String;
    var variables_page_text:URLVariables = new URLVariables();
    var varSend_page_text:URLRequest = new URLRequest("MyPHP.php");
    varSend_page_text.method = URLRequestMethod.POST;
    varSend_page_text.data = variables_page_text;
    var varLoader_page_text:URLLoader = new URLLoader;
    varLoader_page_text.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader_page_text.addEventListener(Event.COMPLETE, var_comp_page_text);
    varLoader_page_text.load(varSend_page_text);
    function var_comp_page_text(event:Event):void {
        MyImportedString =  event.target.data.MyVariable;
         trace(MyImportedString);        // Output:  some text &%^+
    php:
    <?php
    header('Content-Type: text/html; charset=utf-8');
    $MyString = "some text &%^+";
    print "MyVariable=" . flash_encode($MyString);
    function flash_encode($string){
         $string = rawurlencode(utf8_encode($string));
         $string = str_replace("%C2%96", "-", $string);
         $string = str_replace("%C2%91", "%27", $string);
         $string = str_replace("%C2%92", "%27", $string);
         $string = str_replace("%C2%82", "%27", $string);
         $string = str_replace("%C2%93", "%22", $string);
         $string = str_replace("%C2%94", "%22", $string);
         $string = str_replace("%C2%84", "%22", $string);
         $string = str_replace("%C2%8B", "%C2%AB", $string);
         $string = str_replace("%C2%9B", "%C2%BB", $string);
         return $string;
    ?>

  • Receiving variables back from php

    basicaly i have narrowed it down to this code
    stop();
    ////// Assign a variable name for our URLVariables object
    var variables:URLVariables = new URLVariables();
    var varSend:URLRequest=new URLRequest("create_member.php");
    varSend.method=URLRequestMethod.POST;
    varSend.data=variables;
    //////// Build the varLoader variable
    var varLoader:URLLoader=new URLLoader  ;
    varLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
    trace(varSend.data.status);
    trace(varLoader.data.status);
    As silly as it sounds, i need the trace to see the error.
    I am using cs4 for this and have not found anything so far to explain why it is not working.
    You can test it out without needing anything on stage.
    This is the error i get and do not know why.
    undefined               is the varSend trace
    TypeError: Error #1010: A term is undefined and has no properties.
    at Untitled_fla::MainTimeline/frame1()              is the varLoader trace
    I need this fixed, but cant find why it is doing it. Any ideas would be greatly accepted.

    There is a full script as well, but I still only get the errors stated. Basicaly I am unable to get any variables back from PHP. They show up an a standard browser window, but that is no good to me. My site is 100% flash and i need to receive data so that i can log people in, retreive their names and info, send custome messages to people on the site or even if only visitors. Without flash seeing the data correctly, I cant do squat.
    if (event.target.data.returnBody=="") {
    output_txt.text="No data coming through";
    } else if(event.target.data.returnBody!=="") {
    output_txt.condenseWhite = true;
             output_txt.htmlText = ""+ event.target.data.returnBody;
      gotoAndStop("_end");
    trace(varLoader.data.status)
    If i only use    --     event.target.data     I do get the info in, but with all the mish-mash that comes with it
    e.g.
    %0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%3Ch2%3EOne%20Last%20Step%20%2D%20Activate%20through%2 0Email%3C%2Fh2%3E%3Ch4%3EOK%20peter%2C%20one%20last%20step%20to%20verify%20your%20email%20 identity%3A%3C%2Fh4%3E%3Cbr%20%2F%3E%0D%0A%20%20%20In%20a%20moment%20you%20will%20be%20sen t%20an%20Activation%20link%20to%20your%20email%20address%2E%3Cbr%20%2F%3E%3Cbr%20%2F%3E%0D %0A%20%20%20%3Cbr%20%2F%3E%0D%0A%20%20%20%3Cstrong%3E%3Cfont%20color=%22%23990000%22%

  • Creating a array from variables passed from php

    I have passed variables from PHP to flash successfully but
    now need to firstly make them into an array. A next button and
    previous button has to trigger the step through the array.
    Any ideas?

    I have a PHP script and I get flash to load the variables
    from it. The code is as follows. Taken out the connection to DB for
    security.
    <?php
    $hostname_conn = "";
    $database_conn = "";
    $username_conn = "";
    $password_conn = "";
    // establish a SQL connection to the host - host, user, pass
    $conn = mysql_pconnect($hostname_conn, $username_conn,
    $password_conn) or trigger_error("The site database appears unable
    to provide a connection. Please contact support.
    ".mysql_error(),E_USER_ERROR); // or die("The site database appears
    unable to provide a SQL connection. Please contact support.");
    // connect to the right DB (there may be multiple db's on the
    server) dbName
    mysql_select_db($database_conn, $conn) or die("The site
    database appears to be unavailable. Please contact support.");
    $qCheck = "SELECT * FROM pics";
    $rsCheck = mysql_query($qCheck) or die("Check Failed :
    ".mysql_error());
    $cCheck = mysql_num_rows($rsCheck);?>
    &img=<?php
    while($row= mysql_fetch_assoc($rsCheck))
    print($row["img"]);
    ?>

  • I want to send a value from JSP file to another JSP file without..

    I want to send a value from one.JSP file to another two.JSP file without to show the content HTML of the one.JSP in two.JSP (with include), only take the values processed in a Bean :
    ===================
    Bean
    package pck;
    import java.io.*;
    public class yyyy {
         public String getXxx() {    
              return cccc;
    ========================
    one.JSP
    <jsp:useBean id="idBean" class="pck.yyyy" scope="??"/>
    <%idBean.setXxx(ccc);%>
    ========================
    two.JSP
    <%@ include file="one.jsp"%>
    <%=idBean.getXxx()%>
    but without to show the content HTML of one.JSP in two.JSP.
    Can someone help me?, please.

    Why don't just put the common code in a separate file and include it in both. i.e. the code that is in one.jsp that is needed by two.jsp could be put in a common file and included in both pages, thus the HTML is separated off. If this will not work, set a boolean value in two.jsp that can be used by one.jsp to decide if the HTML should be displayed or not.
    Steve

  • How to derive a variable value from another variable of a different IO?

    Hi Gurus,
    I am aware that using BEx variables and Customer Exit you are able to derive a variable value from another variable of the same infoobject (for example, Fiscal Year/Period (0FISCPER) and Calendar Day (0CALDAY)).
    However, is is possible, using the same approach to derive a variable value from another variable that is in a different InfoObject? (for example, Input Fiscal Year/Period (0FISCPER) but derive Output of Required Start Date (0REQSTDAT))?
    There are 2 BEx variables involved,
    1) A user entry variable that is restricted in 0FISCPER
    2) A customer exit variable that is restricted in ZREQSTDAT
    In CMOD under EXIT_SAPLRRS0_001, Include ZXRSRU01, the code (I assume, correct me if I'm wrong) should perform 3 functions in I_STEP = 2,
    1) After the pop up, capture user entry of Fiscal Year/Period
    2) Identify or convert Fiscal Year/Period to Calendar Day range (unsure on how to code this portion)
    3) Use the Calendar Day to lookup on matching Required Start Date and display all Required Start Date that matches. (unsure on how to code on this portion)
    Hope to hear your thoughts soon.
    Regards,
    Eric

    Hi Shanthi,
    I've made the necessary adjustments. The only difference in my code is,
    Instead of,
    If I_VNAM = 'ZREQSTDAT'
    I use,
    CASE I_VNAM.
    Instead of,
    PARAMETERS: ZFISCPER TYPE /BI0/OIFISCPER.
    ZYEAR = ZFISCPER(4).
    ZMM = ZFISCPER+4(3).
    I use ,
    This is the Customer Exit Variable in ZREQSTDAT
    WHEN 'ZRSD_CX'.
    The loop I use for the User Entry Variable in 0FISCPER-ZFYP_IN
      LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
          WHERE VNAM = 'ZFYP_IN'.
        IF SY-SUBRC = 0.
            CLEAR L_S_RANGE.
    ZYEAR = LOC_VAR_RANGE(4).
    ZMM = LOC_VAR_RANGE+4(3).
    The codes were checked with no errors.
    However, when I input the Fiscal Year/Periods and hit 'Execute'. The report went blank, not sure what is the cause. I've tried it several times. No error message appeared.
    Regards,
    Eric

  • Sending novell command from PHP

    Hi,
    I am trying to unzip a file from php.
    I am trying to run a unzip command from phpm but the novell server won't take it.
    when i do: <?php exec("unzip DATA1:/zipfile.zip"); ?>
    i get: unable to find load file SYS:/TMP/UNZIP
    when i do: <?php exec("echo unzip DATA1:/zipfile.zip"); ?>
    i get: unable to find load file SYS:/TMP/ECHO
    when i do: <?php exec("echo unzip "); ?>
    i get: unzip.nlm load status KenelOnly
    Does someone know how to send a command from php to Novell correctly??
    Thank you,

    Have you tried specifying the path with something like
    <?php exec("sys:/system/unzip DATA1:/zipfile.zip"); ?>
    Wolfgang
    "Flex Travel - Higo Rocha Cidario" <[email protected]> wrote in message
    news:oE0uh.7409$[email protected]..
    > Hi,
    >
    > I am trying to unzip a file from php.
    > I am trying to run a unzip command from phpm but the novell server won't
    > take it.
    >
    > when i do: <?php exec("unzip DATA1:/zipfile.zip"); ?>
    > i get: unable to find load file SYS:/TMP/UNZIP
    >
    > when i do: <?php exec("echo unzip DATA1:/zipfile.zip"); ?>
    > i get: unable to find load file SYS:/TMP/ECHO
    >
    > when i do: <?php exec("echo unzip "); ?>
    > i get: unzip.nlm load status KenelOnly
    >
    > Does someone know how to send a command from php to Novell correctly??
    >
    > Thank you,
    >

  • How to transfer variable value from one query to another query?

    I create two queries which contain the same variable "Year" and "Month".
    In the wad,Query1 is used to be a table and Query2 is used to show the chart in the condition with the same variable value of Query1
    So I want to transfer the variable  value from query1 to query2.
    Can anyone help me ?

    Let me explain the issue in detail.
    In Query Designer, both the year and  month variables are defined by user exit function to read current year and month and can be modified  during the query runtime.
    In WAD, Query1 is  used  to be a table with a table interface to hyperlink a chart which is defined by Query2 with the same variable value of Query1.
    During the runtime of template, if I change the variable value of Query1 , I want the variable of Query2 to be changed automatically with the same new value.
    So in the table interface of Query1 , I write the ABAP code in "SE24" and related source code to the variable is following:
    concatenate
    'function fire_urlJGSP_Col(filter) {'
    Cl_rsr_www_renderer=>c_lf
    'chart_url="' url '" + "&CMD=LDOC'
    '&TEMPLATE_ID=GCCHART_9' "WEB ID of the work book
    '&PAGEID=Graphics'       "Name of the view
    '&CMD=PROCESS_VARIABLES&SUBCMD=VAR_SUBMIT&VAR_NAME=Z2MYEAR&VAR_VALUE_EXT=" + filter'
    Cl_rsr_www_renderer=>c_lf
    'openWindow(chart_url,"chart_window","dependent=yes","600",'
    '"450","true")'
    Cl_rsr_www_renderer=>c_lf
    into l_coding.
    In this way , I can only transfer the year variable value from Query1 to Query2 and not two variables .
    So , how  shall I do to transer the two variable value in the same?

  • Passing variable values from WAD to BEx

    Hi Experts,
    I am working with a query which is included in a web template. At the top of this template, I have several variables included in drop down boxes for the user to navigate through the data.
    With clicking at "open in Excel" a BEx-Query is started.
    My question: How can I pass the variable values from those drop down boxes to my Query in BEx?
    The current HTML code for starting the Excel BEx-Query looks like this:
    http://sapserver:port/x/x/x/rsr_bex_launch/bexanalyzerportalwrapper.htm?QUERY=Queryname
    Thanks in advance
    Marco

    If you export your report after selecting required drop down values, your report will be saved to Excel as it was filtered. You do not need any HTML code for this.
    My question: How can I pass the variable values from those drop down boxes to my Query in BEx?
    Why do you want to re-execute your query when you have already ouptut in the first screen shot?

  • Passing global variable values from databse to forms

    I am using forms 6i and database is oracle 9i.
    I am trying to run a form stand alone ( by pressing CTRL-R) without putting it in the application.
    since when this form is placed in the application menu it works fine as it has been passed global variables values from the database .
    now i am trying to run the form without menu and thus i want to pass the values of global variables .please let me know where should i pass these values in form .is it be WHEN-NEW-FORM-Instance trigger or in Pre-form trigger.
    i know what are the global variable values passing into the form from database.
    i can hard code any values to check if the form runs well or not.

    If you intend to do this sort of testing regularly you might want to consider creating a seperate form with a control block which allows entry of the name of the form you want to run, the names of the globals and their values, and do a CALL_FORM.

  • Loading an xml file from an xml file

    I'm trying to load an xml file from an xml file, but I'm
    having problems. My first xml file is really simple - it only
    contains one attribute with the name of another xml file in it
    (eventually I will have multiple xml files in here and run a loop
    on them...this is why I want to load an xml file from an xml file).
    Currently, with the code below, I can get the main xml file
    to load ("main.xml"), but I cannot get the secondary xml files to
    load FROM the main.xml.
    I want to then take childNode values from the secondary xml
    file and use them within my .swf in text boxes and whatnot.
    Any guidance? I think I'm going wrong on the line where I'm
    saying "i.newxml.load(i.attributes.location);"
    - How can I get this to work?

    johnypeter:
    I tried changing the code inside the loop to use just
    "newxml" instead of "i.newxml", and I declared with "var newxml =
    new XML();" - was this what you were thinking?
    kglad:
    The reason I tried to use the loadXML() function in the loop
    was so that for each node in my "main.xml" it would load the new
    xml file listed - this is a no-no? Do you have any ideas as to what
    I could do?
    For the for-loop, what should I change in it? I'm not great
    with loops so I tried to modify some code from another loop I found
    in another forum thread - not the right way to do it here?
    Also, what should I trace? The value of the _root.address, or
    i.attributes.location? I have created dynamic text boxes on my
    stage to see if the correct value from the xml file loads (ie. the
    name of the xml file within the xml file) and it does, but now I
    don't know how to put that information into ANOTHER loadXML()
    function and get the node information from it - does that make
    sense???
    Below are the examples of the xml files I am using. In the
    first one, main.xml, I will have a list of multiple xml files, each
    with the same nodes and elements as in the details.xml file
    (different values, of course).
    This is just to give you an example of what I'm trying to
    accomplish - pulling ALL the addresses and phone numbers from
    multiple xml files. I cannot manually collect this information, as
    it is dynamic, and will be updated in each individual details.xml.
    I was hoping to collect the information by simply adding to and
    updating ONE xml file - main.xml.
    Do you think this can be done? Am I going about it the wrong
    way? I'm quite limited in AS knowledge, which is why I'm piecing
    together code from other posts!

  • Build a web gallery with amazing flash slideshows with dynamic XML files

    Build a web gallery with amazing flash slideshows with dynamic XML files
    Screenshot:
    Features
    Features
    Transitions, zooming and panning effect You can  choose from  Random, Wipe from Left, Fade to White, Cross Expansion and  other 60-plus  transition effects. Zooming and panning effect is  optional for advanced flash  templates.
    XML-driven This flash slideshow are XML-driven. The XML  document allows more personalized controls over the flash.
    Auto-playback and repeat mode The flash slideshow will play  automatically after preloading, and it can repeat playback.
    Dynamic customization Besides XML control, the  advanced  templates provide many more custom options, so that you can  create slideshow  that fits into your existing web design: width ,  height, border color,  background color, thumbnail size, etc. More about  dynamic customization
    Usage and demo visit: http://webdesigndevelopment.blog.com...swf-xml-files/

    Please excuse the bump...
    Anyone with a LR flash gallery that starts with slideshow in play mode?
    Can it even be set to do this?
    The only code in the style.xml that looks like it might be realted is line 12 <playOptions playMode="pause"/>, changing that to "play" does nothing.
    Thanks,
    Donnie

  • Loading an xml file from jws : a nightmare !

    Hi all:
    I'm trying to load a xml file packed inside a jar file, and when i call getresource it keeps always returning null !!!
    When i run the application (not in JWS) the file is loaded, but when i run it from a jnlp file with jws no !!
    I tried all possible solutions wihout success :(
    the last portion of code i used is :
    ClassLoader cl = this.getClass().getClassLoader();
         URL xmlFile=cl.getResource("configure.xml"); why is it working when run from Eclipse but fails when using jws ?
    I packed all my .class files together with xml file in one jar.
    please help me ! this stuff is driving me crazy :(
    thanks.

    Hi phasse !
    Yes I've fortenatly managed to solve my problem .here is the desription:
    Actually my problem was not with loading the xml file but in reading it .
    my problem was in the statement builder.parse(xmlFile.getPath()); this will not work with jws .I replaced this with : Document document = null;
              try {
                    ClassLoader cl = this.getClass().getClassLoader();
                   DocumentBuilderFactory factory = DocumentBuilderFactory
                             .newInstance();
                   DocumentBuilder builder = factory.newDocumentBuilder();
                      document=builder.parse(cl.getResourceAsStream("resources/configure.xml"));I would suggest to use ClassLoader and getResourceAsStream("xmlfile") method .
    I hope this would be helpfull for you .Good luck !

  • Generating XML from SQL queries and saving to an xml file?

    Hi there,
    I was wondering if somebody could help with regards to the following:
    Generating XML from SQL queries and saving to a xml file?
    We want to have a procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
    is accessed by our software on the client machine).
    Using this order number we do a couple of SQL queries.
    My first question: What would be our best option to convert the result of the
    queries to xml?
    Second Question: Once the XML has been generated, how do we save that XML to a file?
    (The XML file is going to be saved on the file system of the server that
    the database is running on.)
    Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
    Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
    the client hard drive.
    Any information would be greatly appreciated.
    Thanking you,
    Francois

    If you are using 9iR2 you do not need to do any of this..
    You can create an XML as an XMLType using the new SQL/XML operators. You can insert this XML into the XML DB repository using DBMS_XDB.createResource. You can then access the document from the resource. You can also return the XMLType containing the XML directly from the PL/SQL Procedure.

  • Generating XML from SQL queries and saving to a xml file?

    Hi there,
    I was wondering if somebody could help with regards to the following:
    Generating XML from SQL queries and saving to a xml file?
    We want to have a stored procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
    is accessed by our software on the client machine).
    Using this order number we do a couple of SQL queries.
    My first question: What would be our best option to convert the result of the
    queries to xml?
    Second Question: Once the XML has been generated, how do we save that XML to a file?
    (The XML file is going to be saved on the file system of the server that
    the database is running on.)
    Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
    Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
    the client hard drive.
    Any information would be greatly appreciated.
    Thanking you,
    Francois

    Hi
    Here is an example of some code that i am using on Oracle 817.
    The create_file procedure is the one that creates the file.
    The orher procedures are utility procedures that can be used with any XML file.
    PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
    pi_root_tag IN VARCHAR2,
                                            po_root_element OUT xmldom.domelement,
                                            po_root_node OUT xmldom.domnode,
                                            pi_doctype_url IN VARCHAR2) IS
    xmldoc xmldom.DOMDocument;
    root xmldom.domnode;
    root_node xmldom.domnode;
    root_element xmldom.domelement;
    record_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
    -- Create the root --
    root := xmldom.makeNode(xmldoc);
    -- Create the root element in the file --
    create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
    po_xmldoc := xmldoc;
    po_root_node := root_node;
    po_root_element := root_element;
    END create_file_with_root;
    PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
    pi_element_name IN VARCHAR2,
                                            pi_parent_node IN xmldom.domnode,
                                            po_new_element OUT xmldom.domelement,
                                            po_new_node OUT xmldom.domnode) IS
    element xmldom.domelement;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    element := xmldom.createElement(pi_xmldoc, pi_element_name);
    child_node := xmldom.makeNode(element);
    -- Append the new node to the parent --
    newelenode := xmldom.appendchild(pi_parent_node, child_node);
    po_new_node := child_node;
    po_new_element := element;
    END create_element_and_append;
    FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
    pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
    parent_node xmldom.domnode;                                   
    child_node xmldom.domnode;
    child_element xmldom.domelement;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
    parent_node := child_node;
    -- Create a text node --
    textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
    child_node := xmldom.makeNode(textele);
    -- Link the text node to the new node --
    compnode := xmldom.appendChild(parent_node, child_node);
    RETURN newelenode;
    END create_text_element;
    PROCEDURE create_file IS
    xmldoc xmldom.DOMDocument;
    root_node xmldom.domnode;
    xml_doctype xmldom.DOMDocumentType;
    root_element xmldom.domelement;
    record_element xmldom.domelement;
    record_node xmldom.domnode;
    parent_node xmldom.domnode;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
    xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
    parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
    parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
    -- write the newly created dom document into the buffer assuming it is less than 32K
    xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
    EXCEPTION
    WHEN xmldom.INDEX_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
    WHEN xmldom.DOMSTRING_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'String Size error');
    WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
    WHEN xmldom.WRONG_DOCUMENT_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
    WHEN xmldom.INVALID_CHARACTER_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
    WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
    WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
    WHEN xmldom.NOT_FOUND_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not found error');
    WHEN xmldom.NOT_SUPPORTED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
    WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
    WHEN OTHERS THEN
    dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
    END create_file;

Maybe you are looking for