Loading XML in AS3

OK, so I think I have the basics of loading XML in AS3. But I
can't seem to access the info once it is loaded. I'm using the to
load the .xml file:
var myXML:XML = new XML();
var XML_URL:String = "music.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(event:Event):void
myXML = XML(myLoader.data);
trace("Data loaded.");
But when I go to trace the .xml file with this:
trace(myXML.toXMLString());
I get nothing. However, if I place this trace inside the
xmlLoaded function it traces it out. My problem is I want access to
the info outside of that function. What am I doing wrong? Any
advice or help would be greatly appreciated. Thanks.

backpages,
> But when I go to trace the .xml file with this:
>
> trace(myXML.toXMLString());
>
> I get nothing.
This looks like a matter of timing. Your first five lines
are
encountered one after the other, starting with var myXML
through
myLoader.addEventListener(), which calls a function defined
immediately
below that. The function is called when the "complete" event
is dispatched,
which may take longer or shorter depending on the size of the
XML document
and network traffic. If you put a trace() statement
immediately below that,
Flash will execute that too -- and at the moment it does,
your XML document
hasn't loaded yet.
> However, if I place this trace inside the xmlLoaded
function it
> traces it out. My problem is I want access to the info
outside
> of that function. What am I doing wrong?
I copy/pasted your code exactly, then followed it with this:
var t:Timer = new Timer(5000);
t.addEventListener(
TimerEvent.TIMER,
function():void {
trace(myXML);
t.start();
... which waits five seconds, then runs that trace(). Sure
enough, it
outputs the XML contents.
If you want to use the myXML variable elsewhere in your
movie, you just
have to make sure those other locations don't reference the
variable until
it has a value (or account for a lack of value in the logic
they use). You
might, for example, put a stop() action in frame one, along
with the
existing code (and instead of my timer), then have the
"complete" event
handler issue a play() action. In later frames, the myXML
variable would
have the data you need, because the playhead won't advance
until the data
have been loaded.
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."

Similar Messages

  • Loading XML in AS3...trying to make a news reader

    Hello! I'm hoping someone can point me in the direction of a tutorial that shows how to create a "News Widget" from an XML file. I'm a designer so I know very little code...any help would really be appreciated!
    I would like to create a Flash file using AS3 that pulls info from three different nodes in an XML file. The pic below is a screen shot of what I'm trying to accomplish.
    Here's an example of my XML:
    <?xml version="1.0"?>
    <rss version="2.0">
    <channel><title>kstp.com - MORE NEWS</title>
    <item>
    <title>State announces details of Minnesota FluLine </title>
    <description><![CDATA[<img alt="" src="http://kstp.com/kstpImages/health_minnesota90.jpg" align="left" border="1" />The Minnesota Health Department will soon become the latest state to announce details of a toll-free nurse line for those... ]]></description>
    <link>http://kstp.com/news/stories/s1202318.shtml?cat=1</link>
    <subject/>
    <creator>kstp.com</creator>
    <pubDate>Wed, 21 Oct 2009 11:38:04 GMT</pubDate>
    </item>
    <item>
    <title>Environmental group to look at MN water pollution </title>
    <description><![CDATA[<img alt="" src="http://kstp.com/kstpImages/water_graphic.jpg" align="left" border="1" />An environmental group releases an analysis of industrial pollution in Minnesota's waters on Wednesday. <font size="2">Environment Minnesota says...</font>]]></description>
    <link>http://kstp.com/news/stories/s1202345.shtml?cat=1</link>
    <subject/>
    <creator>kstp.com</creator>
    <pubDate>Wed, 21 Oct 2009 10:13:46 GMT</pubDate>
    </item>
    </channel>
    </rss>
    For each row I would like to display the <title> info, <description> info and wrap all of that up in the <link> URL.
    I imaging there is a good tutorial out there but I don't know enough to search using the correct terms.
    Any help would be AWESOME!!
    Thank you!
    Melissa

    You're probably not going to find too much in the way of a tutorial that arranges the content exactly the way you want it laid out.  I'm not sure what you mean when you say you want an example of how to display more than one node's worth of information.  From what I remember that tutorial has several entries, each having a few pieces of information.
    Because some of your data appears to be html formatted, it may make it a little harder for you to control the layout.  You will probably have to go with some movieclip/textfield(s) combination in order to be able to format things the way you showed, possibly making use of the textfield's htmlText property.

  • Load XML file from addon domain without cross-domain Policy file

    Hello.
    Assuming that there are two addon domains on the same server: /public_html/domain1.com       and      /public_html/domain2.com
    I try to load XML file from domain2.com into domain1.com without using cross-domain policy file (since it doesn’t work on xml files in my case).
    So the idea is to use php file in order to load XML and read it back to flash.
    I’ve found an interesting scripts that seems to do the job but unfortunately I can't get it to work. In my opinion there is somewhere problem with AS3 part. Please take a look.
    Here are the AS3/PHP scripts:
    AS3 (.swf in www.domain1.com):
    // location of the xml that you would like to load, full http address
    var xmlLoc:String = "http://www.domain2.com/MyFile.xml";
    // location of the php xml grabber file, in relation to the .swf
    var phpLoc:String = "loadXML.php";
    var xml:XML;
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest(phpLoc+"?location="+escape(xmlLoc) );
    loader.addEventListener(Event.COMPLETE, onXMLLoaded);
    loader.addEventListener(IOErrorEvent.IO_ERROR, onIOErrorHandler);
    loader.load(request);
    function onIOErrorHandler(e:IOErrorEvent):void {
        trace("There was an error with the xml file "+e);
    function onXMLLoaded(e:Event):void {
        trace("the rss feed has been loaded");
        xml = new XML(loader.data);
        // set to string, since it is passed back from php as an object
        xml = XML(xml.toString());
        xml_txt.text = xml;
    PHP (loadXML.php in www.domain1.com):
    <?php
    header("Content-type: text/xml");
    $location = "";
    if(isset($_GET["location"])) {
        $location = $_GET["location"];
        $location = urldecode($location);
    $xml_string = getData($location);
    // pass the url encoded vars back to Flash
    echo $xml_string;
    //cURLs a URL and returns it
    function getData($query) {
        // create curl resource
        $ch = curl_init();
        // cURL url
        curl_setopt($ch, CURLOPT_URL, $query);
        //Set some necessary params for using CURL
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       //Execute the curl function, and decode the returned JSON data
        $result = curl_exec($ch);
        return $result;
        // close curl resource to free up system resources
        curl_close($ch);
    ?>

    I think you might be right about permissions/settings on the server for php. Unfortunately I'm not allowed to adjust them.
    So I wrote my own script - this time I used file path instead of http address of the XML file.  It works fine in my case.
    Here it is:
    XML file on domain2.com:
    <?xml version="1.0" encoding="UTF-8"?>
    <gallery>
        <image imagePath="galleries/gallery_1/images/1.jpg" thumbPath="galleries/gallery_1/thumbs/1.jpg" file_name= "1"> </image>
        <image imagePath="galleries/gallery_1/images/2.jpg" thumbPath="galleries/gallery_1/thumbs/2.jpg" file_name= "2"> </image>
        <image imagePath="galleries/gallery_1/images/3.jpg" thumbPath="galleries/gallery_1/thumbs/3.jpg" file_name= "3"> </image>
    </gallery>
    swf  on domain1.com:
    var imagesXML:XML;
    var variables:URLVariables = new URLVariables();
    var varURL:URLRequest = new URLRequest("MyPHPfile.php");
    varURL.method = URLRequestMethod.POST;
    varURL.data = variables;
    var MyLoader:URLLoader = new URLLoader;
    MyLoader.dataFormat =URLLoaderDataFormat.VARIABLES;
    MyLoader.addEventListener(Event.COMPLETE, XMLDone);
    MyLoader.load(varURL);
    function XMLDone(event:Event):void {
        var imported_XML:Object = event.target.data.imported_XML;
        imagesXML = new XML(imported_XML);
       MyTextfield_1.text = imagesXML;
       MyTextfield_2.text = imagesXML.image[0].attribute("thumbPath");  // sample reference to attribute "thumbPath" of the first element
    php file on domain1.com:
    <?php
    $xml_file = simplexml_load_file('../../domain2.com/galleries/gallery_1/MyXMLfile.xml');  // directory to XML file on the same server
    $imported_XML = $xml_file->asXML();
    print "imported_XML=" . $imported_XML;
    ?>
    Regards
    PS: for those who read the above discussion: the first and the second script work but you must test which one is better in your situation. The first script will also work between two domains on different servers. No cross domain policy file needed.

  • Loading XML generated by PHP doesn´t work

    I know what will you say: Search for a tutorial.
    Yes, i´ve searched here. Through internet. But i get no answer.
    I checked format. This is the xml output:
    <?xml version="1.0" ?>
    <root>
    <nivel nombre='A1'>
    <item>
    <nombre>audio1</nombre>
    <tipo>audio</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Audios/A1_audio1.MP3</url>
    </item>
    </nivel>
    <nivel nombre='A2'>
    <item>
    <nombre>leccion1</nombre>
    <tipo>texto</tipo>
    <descargable>si</descargable><nivel nombre='B1'><item>
    <nombre>audio1</nombre>
    <tipo>audio</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Audios/B1_audio1.MP3</url>
    </item>
    </nivel>
    </root>
    I think the format is perfect. I can read it on my Firefox as a perfect xml.
    Now. This is action script code:
                var loader:URLLoader = new URLLoader();
                loader.addEventListener(Event.COMPLETE, cargaXML);
                loader.load(new URLRequest("reproductor_generador_datos.php"));
    When loaded i do
    trace(e.target.data);
    To see the xml, but it´s php. It hasn´t generated it.
    I follow every tutorial. This is the way. Is there any other way to make it "EXECUTE" the php code?? it donesn´t seem to work.
    The same happens when i assign it to an XML in AS3. It doesn´t work.
    Please help me. It´s taking so many time.
    Thanks!!

    Thanks a lot for the help, guys.
    Well. I think i had problems trying to copy the xml here. That´s why it´s broken.... but i don´t find the problem, though, there...
    Let me post here another example on how is it now. It´s got the header, and the <?xml tag.
    <root>
    <item>
    <nivel>A1</nivel>
    <id>0</id>
    <nombre>audio1</nombre>
    <tipo>audio</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Audios/A1_audio1.MP3</url>
    </item>
    <item>
    <nivel>A2</nivel>
    <id>1</id>
    <nombre>leccion1</nombre>
    <tipo>texto</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Textos/A2_leccion1.pdf</url>
    </item>
    <item>
    <nivel>A2</nivel>
    <id>2</id>
    <nombre>leccion1</nombre>
    <tipo>texto</tipo>
    <descargable>no</descargable>
    <url>
    ../multimedia/Textos/no_descargable/A2_leccion1.pdf
    </url>
    </item>
    <item>
    <nivel>A2</nivel>
    <id>3</id>
    <nombre>audio1</nombre>
    <tipo>audio</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Audios/A2_audio1.MP3</url>
    </item>
    <item>
    <nivel>A2</nivel>
    <id>4</id>
    <nombre>audio1</nombre>
    <tipo>audio</tipo>
    <descargable>no</descargable>
    <url>../multimedia/Audios/no_descargable/A2_audio1.MP3</url>
    </item>
    <item>
    <nivel>A3</nivel>
    <id>5</id>
    <nombre>esFolleto2009</nombre>
    <tipo>texto</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Textos/A3_esFolleto2009-2010.pdf</url>
    </item>
    <item>
    <nivel>A3</nivel>
    <id>6</id>
    <nombre>leccion1</nombre>
    <tipo>texto</tipo>
    <descargable>no</descargable>
    <url>
    ../multimedia/Textos/no_descargable/A3_leccion1.pdf
    </url>
    </item>
    <item>
    <nivel>A3</nivel>
    <id>7</id>
    <nombre>Avicena</nombre>
    <tipo>video</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Videos/A3_Avicena.flv</url>
    </item>
    <item>
    <nivel>B1</nivel>
    <id>8</id>
    <nombre>audio1</nombre>
    <tipo>audio</tipo>
    <descargable>si</descargable>
    <url>../multimedia/Audios/B1_audio1.MP3</url>
    </item>
    <item>
    <nivel>B1</nivel>
    <id>9</id>
    <nombre>audio1</nombre>
    <tipo>audio</tipo>
    <descargable>no</descargable>
    <url>../multimedia/Audios/no_descargable/B1_audio1.MP3</url>
    </item>
    </root>
    well. maybe i fixed it ... lol... but i think it won´t work.

  • How to load XML File to BW Delta Queue via Webpage

    Hello altogether,
    I am trying to load an CSV file via Webpage (the Webpage have to change the csv file in a xml/soap file) into BW Delta Queue.
    Steps that I have made:
    - Create an InfoSource
    - Create an BW Data Source with Soap Connection
    - Create an initial Delta without Data Transfer
    - Create a Web Service with TC - SE37 - Utilities -> More Utilities -> Create Web Service
    If I test the Web Service with TC - Soamanager (BW 7.0), the data entered here, are transferred to the BW Delta Queue.
    If I test the function module ( TC - SE37), the data also transferred to the Delta Queue.
    Now I think, that I have an error in the html file or the html file is not conform to the wsdl document?? Or should I have to create a virtual interface, but I don't find a possibility to creat it...???
    Can you please help me????
    The coding of the WSDL Document and the Website is attached (I can also send you the coding and error message via mail, if you want). Sorry I don't know how to display here the coding. I try it with symbol "click to display the text code", but afterwards I get an error message from the website...   So let me please know your mail address and I send it via mail....
    I hope, that somebody can help me!!!!!
    Edited by: Alina99 on Sep 8, 2009 11:44 AM
    Error Message from BW:
    ...sap-env:envelope..... soap-env:body><soap-env:fault><faultcode>soap-env:Client</faultcode></faultstring xml:lang="eng">Virtual Interface Method&gt;_-BI0_-QI6AZ_XML_APPL2_RFC::urn:sap-com:document:sap:soap:functions:mc-style&lt;not supported</faultstring>.......
    Edited by: Alina99 on Sep 8, 2009 11:56 AM

    Hello,
    I have done all the necessary config in BW. However, as I mentioned earlier, we are still not up with XI so I am trying to load XML to BW delta queue.  The question still remains, how do I make make the XML file (on my desktop say) point to the BW so the InfoPackage picks up and places in the delta queue?  Even if I had XI, there has to be a way whereby BW looks for the XML file.  That is what I want to know and stuck at.
    Any detailed step by step help will be appreciated as always.
    Cheers

  • Rtf template taking long time to load xml

    Dear All
    rtf template taking long time to load xml and Insert fields. I am using MS office2010. It was working before.
    can any one help me out.
    Regards
    Arifuddin

    Hi;
    Pelase review below which could be helpful for you
    XML Publisher Report Issues, Recommendations and Errors [ID 862644.1]
    Regard
    Helios

  • Problem to load XML SQL Utility into other user

    Hi,
    I need help to load XML Utility into other user than
    "scott"tiger".
    I loaded both xmlparser.jar and oraclexmlsql.jar into
    "scott/tiger", it works and creating functions and testing work
    fine. But when change USER_PASSWORD to another user, it gave me
    some errors like
    creating : org/xml/sax/helpers/AttributeListImpl
    Error while creating class org/xml/sax/helpers/AttributeListImpl
    ORA-29506: invalid query derived from USING clause
    ORA-00942: table or view does not exist
    Error while accessing MD5 table
    ORA-00942: table or view does not exist
    Do I need create any table or view for my another oracle account?
    Or did I missed any thing. From the installation instruction, I
    cano not find any about creating table or view before I load the
    two jar files.
    Thanks
    Yuping
    null

    Hi Yuping,
    Great to hear that! Thx for posting the solution to the
    problem! Let us know if you have any problems with the utility
    or if u need any enhancements!
    Thx
    Murali
    Yuping Zhu (guest) wrote:
    : Hi,Murali,
    : The problem is fixed now. When load xmlparser into the user, it
    : creates two tables automatically, my mistake is I did not grant
    : "create table" privilege to the user. After I granted the
    : privilege to it, it works fine.
    : Thanks!
    : Yuping
    : Murali K (guest) wrote:
    : : Hi,
    : : I will check this out with the Java folks and let u know
    : : Thx
    : : Murali K
    : : Yuping Zhu (guest) wrote:
    : : : Hi, Murali
    : : : I'm using Oracle8i on Solaris 2.6. When I load xmlparser
    : using
    : : : loadjava -resolve -verbose -user $USER_PASSWORD
    xmlparser.jar
    : : : I get error message and I catch part of erros
    : : : PS, I can load it into scott/tiger.
    : : : Thanks!
    : : : Yuping
    : : : loading : org/w3c/dom/html/HTMLLegendElement
    : : : Error while loading org/w3c/dom/html/HTMLLegendElement
    : : : ORA-04068: existing state of packages has been
    discarded
    : : : ORA-04063: package body "IOEXML.LOADLOBS" has errors
    : : : ORA-06508: PL/SQL: could not find program unit being called
    : : : ORA-06512: at line 1
    : : : creating : org/w3c/dom/html/HTMLLegendElement
    : : : Error while creating class
    org/w3c/dom/html/HTMLLegendElement
    : : : ORA-29506: invalid query derived from USING clause
    : : : ORA-00942: table or view does not exist
    : : : Error while accessing MD5 table
    : : : ORA-00942: table or view does not exist
    : : : loading : org/w3c/dom/html/HTMLImageElement
    : : : Error while loading org/w3c/dom/html/HTMLImageElement
    : : : ORA-04068: existing state of packages has been
    discarded
    : : : ORA-04063: package body "IOEXML.LOADLOBS" has errors
    : : : ORA-06508: PL/SQL: could not find program unit being called
    : : : ORA-06512: at line 1
    : : : creating : org/w3c/dom/html/HTMLImageElement
    : : : Error while creating class
    org/w3c/dom/html/HTMLImageElement
    : : : ORA-29506: invalid query derived from USING clause
    : : : ORA-00942: table or view does not exist
    : : : Error while accessing MD5 table
    : : : ORA-00942: table or view does not exist
    : : : loading : oracle/xml/parser/v2/XSLException
    : : : Error while loading oracle/xml/parser/v2/XSLException
    : : : ORA-04068: existing state of packages has been
    discarded
    : : : ORA-04063: package body "IOEXML.LOADLOBS" has errors
    : : : ORA-06508: PL/SQL: could not find program unit being called
    : : : ORA-06512: at line 1
    : : : Murali K (guest) wrote:
    : : : : Hi Yuping,
    : : : : I tried the same on a 8i database and it seems to be
    : : working
    : : : : fine. (loading into two schemas). In fact I just created
    : the
    : : : : other user and it doesnt have any tables or anything in
    it.
    : : : : You do not need to create anything (table/view) extra
    for
    : : : these
    : : : : to work.
    : : : : Which database (Oracle8 or 8i) are u using?
    : : : : Thanks
    : : : : Murali
    : : : : Yuping Zhu (guest) wrote:
    : : : : : Hi,
    : : : : : I need help to load XML Utility into other user than
    : : : : : "scott"tiger".
    : : : : : I loaded both xmlparser.jar and oraclexmlsql.jar into
    : : : : : "scott/tiger", it works and creating functions and
    : testing
    : : : work
    : : : : : fine. But when change USER_PASSWORD to another user,
    it
    : : gave
    : : : me
    : : : : : some errors like
    : : : : : creating : org/xml/sax/helpers/AttributeListImpl
    : : : : : Error while creating class
    : : : : org/xml/sax/helpers/AttributeListImpl
    : : : : : ORA-29506: invalid query derived from USING clause
    : : : : : ORA-00942: table or view does not exist
    : : : : : Error while accessing MD5 table
    : : : : : ORA-00942: table or view does not exist
    : : : : : Do I need create any table or view for my another
    oracle
    : : : : account?
    : : : : : Or did I missed any thing. From the installation
    : : instruction,
    : : : I
    : : : : : cano not find any about creating table or view before
    I
    : : load
    : : : : the
    : : : : : two jar files.
    : : : : : Thanks
    : : : : : Yuping
    null

  • Error while loading xml files using JDBC

    Hi,
    I am trying to load xml files into an xmltype table using JDBC calls and am getting this error for some files
    LPX-00200: could not convert from encoding UTF-8 to UCS2
    The xml files and our database are both UTF-8 encoded. The version of oracle that we have here is 9.2.0.6
    Any suggestions in this matter will be greatly appreciated.
    Thanks,
    Uma

    I also experienced this problem and unfortunately this solution didn't work for me given that the tag you suggested was already on the XML file.

  • Special Characters while loading xml file in rtf template

    Hello,
    We use Oracle BI Publisher Enterprise to develop and publish reports. I am self taught and I am used to developing reports the following way
    1) Write SQL query
    2) View the Data format and copy the xml from the browser
    3) put in in textpad and use block mode to get rid of the hyphens
    4) save the xml on the desktop
    6) Now start a new rtf and go to plugins and load xml data
    7) load the xml data and then generate a tabular or cross tab report using the toolbar in plugins
    Now in step 6 when I try to load the xml data I am getting an error because some of the data elements have '<' or '>' than signs.
    What are my options now and how do I fix the xml to escape or put cdata sections around the special characters? Is there a better way to develop reports using the GUI?
    Thanks

    Hello,
    We use Oracle BI Publisher Enterprise to develop and publish reports. I am self taught and I am used to developing reports the following way
    1) Write SQL query
    2) View the Data format and copy the xml from the browser
    3) put in in textpad and use block mode to get rid of the hyphens
    4) save the xml on the desktop
    6) Now start a new rtf and go to plugins and load xml data
    7) load the xml data and then generate a tabular or cross tab report using the toolbar in plugins
    Now in step 6 when I try to load the xml data I am getting an error because some of the data elements have '<' or '>' than signs.
    What are my options now and how do I fix the xml to escape or put cdata sections around the special characters? Is there a better way to develop reports using the GUI?
    Thanks

  • Error While Loading XMl Doc into Oracle Database 10g

    Hi all,
    I have a task that , I have to make a utillity by which we can load XML Doc into a Table. While searching on Internet i found following Procedure on ASK Tom
    CREATE OR REPLACE
    procedure insert_xml_emps(
    p_directory in varchar2, p_filename in varchar2, vtableName in varchar2 )
    as
    v_filelocator bfile;
    v_cloblocator clob;
    l_ctx dbms_xmlsave.ctxType;
    l_rows number;
    begin
    dbms_lob.createtemporary(v_cloblocator,true);
    v_filelocator := bfilename(p_directory, p_filename);
    dbms_lob.open(v_filelocator, dbms_lob.file_readonly);
    DBMS_LOB.LOADFROMFILE(v_cloblocator, v_filelocator,
    dbms_lob.getlength(v_filelocator));
    l_ctx := dbms_xmlsave.newContext(vTableName);
    l_rows := dbms_xmlsave.insertxml(l_ctx,v_cloblocator);
    dbms_xmlsave.closeContext(l_ctx);
    dbms_output.put_line(l_rows || ' rows inserted...');
    dbms_lob.close(v_filelocator);
    DBMS_LOB.FREETEMPORARY(v_cloblocator);
    end ;
    when i try to run this procedure
    BEGIN
    insert_xml_emps('XML_LOAD','load.xml','IBSCOLYTD');
    END;
    it gaves me following Error
    ORA-29532: java call terminated by uncaught java exception : Oracle.xml.sql.OracleXMLSQLException:No
    rows to modify-- the row enclosing tag missing. Specify the correct row enclosing tag.
    ORA-06512: at "SYS.DBMS_XMLSAVE", line 115
    ORA-06512: at "EXT_TEST.INSERT_XML_EMPS", line 18
    ORA-06512: at line 2
    Can anyone describe me this error
    Thanks.
    Best Regards.

    SQL> /* Creating Your table */
    SQL> CREATE TABLE IBSCOLYTD
      2  (
      3  ACTNOI VARCHAR2 (8),
      4  MEMONOI NUMBER (7,0),
      5  MEMODTEI DATE,
      6  AMOUNTI NUMBER (8,0),
      7  BRCDSI NUMBER (4,0),
      8  TYPEI NUMBER (4,0),
      9  TRANSMONI NUMBER (6,0)
    10  );
    Table created.
    SQL> CREATE OR REPLACE PROCEDURE insert_xml_emps(p_directory in varchar2,
      2                                              p_filename  in varchar2,
      3                                              vtableName  in varchar2) as
      4    v_filelocator    BFILE;
      5    v_cloblocator    CLOB;
      6    l_ctx            DBMS_XMLSTORE.CTXTYPE;
      7    l_rows           NUMBER;
      8    v_amount_to_load NUMBER;
      9    dest_offset      NUMBER := 1;
    10    src_offset       NUMBER := 1;
    11    lang_context     NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    12    warning          NUMBER;
    13  BEGIN
    14    dbms_lob.createtemporary(v_cloblocator, true);
    15    v_filelocator := bfilename(p_directory, p_filename);
    16    dbms_lob.open(v_filelocator, dbms_lob.file_readonly);
    17    v_amount_to_load := DBMS_LOB.getlength(v_filelocator);
    18    ---  ***This line is changed*** ---
    19    DBMS_LOB.LOADCLOBFROMFILE(v_cloblocator,
    20                              v_filelocator,
    21                              v_amount_to_load,
    22                              dest_offset,
    23                              src_offset,
    24                              0,
    25                              lang_context,
    26                              warning);
    27 
    28    l_ctx := DBMS_XMLSTORE.newContext(vTableName);
    29    DBMS_XMLSTORE.setRowTag(l_ctx, 'ROWSET');
    30    DBMS_XMLSTORE.setRowTag(l_ctx, 'IBSCOLYTD');
    31    -- clear the update settings
    32    DBMS_XMLStore.clearUpdateColumnList(l_ctx);
    33    -- set the columns to be updated as a list of values
    34    DBMS_XMLStore.setUpdateColumn(l_ctx, 'ACTNOI');
    35    DBMS_XMLStore.setUpdateColumn(l_ctx, 'MEMONOI');
    36    DBMS_XMLStore.setUpdatecolumn(l_ctx, 'MEMODTEI');
    37    DBMS_XMLStore.setUpdatecolumn(l_ctx, 'AMOUNTI');
    38    DBMS_XMLStore.setUpdatecolumn(l_ctx, 'BRCDSI');
    39    DBMS_XMLStore.setUpdatecolumn(l_ctx, 'TYPEI');
    40    DBMS_XMLStore.setUpdatecolumn(l_ctx, 'TRANSMONI');
    41    -- Now insert the doc.
    42    l_rows := DBMS_XMLSTORE.insertxml(l_ctx, v_cloblocator);
    43    DBMS_XMLSTORE.closeContext(l_ctx);
    44    dbms_output.put_line(l_rows || ' rows inserted...');
    45    dbms_lob.close(v_filelocator);
    46    DBMS_LOB.FREETEMPORARY(v_cloblocator);
    47  END;
    48  /
    Procedure created.
    SQL> BEGIN
      2  insert_xml_emps('TEST_DIR','load.xml','IBSCOLYTD');
      3  END;
      4  /
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM ibscolytd;
    ACTNOI      MEMONOI MEMODTEI     AMOUNTI     BRCDSI      TYPEI  TRANSMONI
    28004125     251942 05-SEP-92        400        513          1          0
    28004125     251943 04-OCT-92        400        513          1          0
    SQL>

  • IDOC_XML_FROM_FILE Error while loading XML as IDOC to ECC 6.0

    I have successfully converted IDOC to XML file.
    Getting Error while converting XML back to IDOC in ECC 6.0 using function: IDOC_XML_FROM_FILE
    Segment EDI_DS40 is not defined.....I am really not sure about the error as this idoc was previously posted to the same ECC 6.0...
    Exception       SEGMENT_ERROR
    Message ID:          EA                         Message number:           721
    Message:
    The segment EDI_DS40 is not defined.
    Secondly is there a way to load XML file via WE19?
    Tx
    Salman

    Thanks alot Oliver for taking a stab...
    I created the XML file from within SAP by using the functionailty of this function module:-
    IDOC_XML_TRANSFORM
    I created my ZIDOC_XML_TRANSFORM and just added file download facility in that the rest is the same as the orignal function.
    Is there any way for me to supress generation of ED_DS40 segements in the XML file??

  • Error while loading XML files into scott user

    Hi All,
    I'm new to xml files. I need to load xml files into database through OWB.
    I have xml file in my local machine & am trying to load into table PO of Scott. Scott is registered as repository user.
    Followed same steps as specified in userguide.
    But, when executing the procedure ( in two ways one as just table name, and other as user.table name) it is showing the below error:
    Procedure is:(1)--with username.tablename
    begin
    wb_xml_load(
    '<OWBXMLRuntime>'||
    '<XMLSource>'||
    '<file>&&SAMPLES_DIR.sample1.xml</file>'||
    '</XMLSource>'||
    '<targets>'||
    '<target dateFormat="yyyy.MM.dd">scott.PO</target>'||
    '</targets>'||
    '</OWBXMLRuntime>'
    end;
    ERROR at line 1:
    ORA-20006: Error occurred while truncating target database object SCOTT.PO.
    Base exception: ORA-01031: insufficient privileges
    ORA-06512: at "OWBSYS.WB_XML_LOAD_F", line 12
    ORA-06512: at "OWBSYS.WB_XML_LOAD", line 4
    ORA-06512: at "SCOTT.SAMPLE1", line 3
    ORA-06512: at line 1
    Procedure is:(2) with out username
    begin
    wb_xml_load(
    '<OWBXMLRuntime>'||
    '<XMLSource>'||
    '<file>&&SAMPLES_DIR.sample1.xml</file>'||
    '</XMLSource>'||
    '<targets>'||
    '<target dateFormat="yyyy.MM.dd">PO</target>'||
    '</targets>'||
    '</OWBXMLRuntime>'
    end;
    ERROR at line 1:
    ORA-20006: Error occurred while truncating target database object PO.
    Base exception: ORA-00942: table or view does not exist
    ORA-06512: at "OWBSYS.WB_XML_LOAD_F", line 12
    ORA-06512: at "OWBSYS.WB_XML_LOAD", line 4
    ORA-06512: at line 2
    xml file:
    <ROWSET>
    <ROW>
    <ID>100</ID>
    <ORDER_DATE>2000.12.20</ORDER_DATE>
    <SHIPTO_NAME>Adrian Howard</SHIPTO_NAME>
    <SHIPTO_STREET>500 Marine World Parkway</SHIPTO_STREET>
    <SHIPTO_CITY>Redwood City</SHIPTO_CITY>
    <SHIPTO_STATE>CA</SHIPTO_STATE>
    <SHIPTO_ZIP>94065</SHIPTO_ZIP>
    </ROW>     
    </ROWSET>
    Note: Everything works fine if I create PO table in OWBSYS user and execute the procedurein OWBSYS user. OWBSYS.PO table will be loaded.
    What privileges are missing, what shouldI do if I want to execute the procedure from scott user and load the table of scott.
    Thanks in advance for the help.
    Regards,
    Joshna

    Hi Joshna,
    Please follow below steps to load xml file to oracle database.
    1.First connect to owb (Design Center) through your repository owner user (ex : REP_OWNER).
    2. Import WB_XML_LOAD procedure . and exit to repository owner.
    3. connect to owb design center through your repository user (ex : REP_USER)
    Create New mapping and drag one Constant Operator and create one attribute, paste / edit following code
    '<OWBXMLRuntime>'||
    '<XMLSource>'||
    '<file>E:\SOURCE\emp.xml</file>'||
    '</XMLSource>'||
    '<targets>'||
    '<target truncateFirst = "FALSE" dateFormat="yyyy.MM.dd">rep_user.emp</target>'||
    '</targets>'||
    '</OWBXMLRuntime>'
    4. Drag pre mapping operator and select WB_XML_LOAD procedure
    5. Connect Constant Operator attribute to pre mapping operator.
    6. Drag two dummy tables and connect source to target. (ex : drag t1 (table) tab two times and connect.
    7. Validate and deploy the mapping.
    8. grant necessary grant command to rep_owner user to rep_user user.
    (Note : target truncateFirst = "FALSE" by default truncate the table. So you have to give grant privileges
    To rep_user , select ,insert, delete privileges.
    9. Execute the mapping , and check EMP table. (Note : before loading EMP table delete all records ).
    10 . If you want more description please go through the below link
    http://download.oracle.com/docs/html/A95931_01/apf.htm
    Regards
    Venkat

  • Load XML records in a normal table

    Good afternoon all,
    I have a very simple question:
    I get a XML file and want to store that data in my Oracle database in a normal table.
    I have seen so many answers everywhere, varying from LOBs and using XDB etc.
    What i don't understand is why it is so difficult.
    When i want to load a CSV file in a table I make a very small Control File CTL and from the command prompt / command line I run the SQL Loader.
    Control file:
    load data
    infile 'import.csv'
    into table emp
    fields terminated by "," optionally enclosed by '"'          
    ( empno, empname, sal, deptno )
    command:
    sqlldr user/password@SID control=loader_Control_File.ctl
    Next I connect to the database and run SQL query:
    select * from emp;
    and i see my data as usual, I can make Crystal Reports on it, etc etc
    I really don't understand why this can't be done with an XML file
    Oracle know the fields in the table EMP
    The xml file has around every field the <EMPNO> and </EMPNO>
    Can't be easier than that I would say.
    I can understand Oracle likes some kind of description of the XML table, so reference to a XSD file would be understandable.
    But all examples are describing LOB things (whatever that is)
    Who can help me to get XML data in a normal table?
    Thanks
    Frank

    Hi Frank,
    What i don't understand is why it is so difficult.Why do you think that?
    An SQL*Loader control file might appear very small and simple to you, but you don't actually see what happens inside the loader itself, I guess a lot of complex operations (parsing, datatype mapping, memory allocation etc.).
    XML, contrary to a CSV format, is a structured, well standardized language and could handle far more complex documents than row-organized CSV files.
    I think it naturally requires a few extra work (for a developer) to describe what we want to do out of it.
    However, using an XML schema is not mandatory to load XML data into a relational table.
    It's useful if you're interested in high-performance loading and scalability, as it allows Oracle to fully understand the XML data model it has to deal with, and make the correct mapping with SQL types in the database.
    Furthermore, now with 11g BINARY XMLType, performance has been improved with or without schema.
    Here's a simple example, loading XML file "import.xml" into table MY_EMP.
    Do you find it difficult? ;)
    SQL> create or replace directory test_dir as 'D:\ORACLE\test';
    Directory created
    SQL> create table my_emp as
      2  select empno, ename, sal, deptno
      3  from scott.emp
      4  where 1 = 0
      5  ;
    Table created
    SQL> insert into my_emp (empno, ename, sal, deptno)
      2  select *
      3  from xmltable('/ROWSET/ROW'
      4         passing xmltype(bfilename('TEST_DIR', 'import.xml'), nls_charset_id('CHAR_CS'))
      5         columns empno  number(4)    path 'EMPNO',
      6                 ename  varchar2(10) path 'ENAME',
      7                 sal    number(7,2)  path 'SAL',
      8                 deptno number(2)    path 'DEPTNO'
      9       )
    10  ;
    14 rows inserted
    SQL> select * from my_emp;
    EMPNO ENAME            SAL DEPTNO
    7369 SMITH         800.00     20
    7499 ALLEN        1600.00     30
    7521 WARD         1250.00     30
    7566 JONES        2975.00     20
    7654 MARTIN       1250.00     30
    7698 BLAKE        2850.00     30
    7782 CLARK        2450.00     10
    7788 SCOTT        3000.00     20
    7839 KING         5000.00     10
    7844 TURNER       1500.00     30
    7876 ADAMS        1100.00     20
    7900 JAMES         950.00     30
    7902 FORD         3000.00     20
    7934 MILLER       1300.00     10
    14 rows selected
    import.xml :
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7369</EMPNO>
      <ENAME>SMITH</ENAME>
      <SAL>800</SAL>
      <DEPTNO>20</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7499</EMPNO>
      <ENAME>ALLEN</ENAME>
      <SAL>1600</SAL>
      <DEPTNO>30</DEPTNO>
    </ROW>
    <!-- more rows here -->
    <ROW>
      <EMPNO>7934</EMPNO>
      <ENAME>MILLER</ENAME>
      <SAL>1300</SAL>
      <DEPTNO>10</DEPTNO>
    </ROW>
    </ROWSET>
    Who can help me to get XML data in a normal table?If you have a specific example, feel free to post it, including the following information :
    - structure of the target table
    - sample XML file
    - database version (select * from v$version)
    Hope that helps.
    Edited by: odie_63 on 9 mars 2011 21:22

  • Load XML file from different location?

    Hi All,
    I've been going through an exercise by Karl Matthews to load XML data into an AIR App:
    http://www.adobe.com/devnet/air/flex/articles/xml_viewer_on_air.html
    but I would like to change where the XML file used in the project is retrieved from.
    Currently the XML file is loaded from here:
    <!-- Set up the HTTP service from where we get the source XML data -->
    <mx:HTTPService id="srcData" url="
    assets/UserGuide.xml" result="loadModelData(event)"
    />
    but I would like to load the XML file from one of these locations instead:
    File.userDirectory:
    File.documentsDirectory:
    Can someone please show me how I should change the above code to accomplish this, as my efforts to date have not been successful :-(
    I am using Flex Builder 3 and Air 1.5.
    Thanks heaps!
    Tim

    Hi Bhasker,
    Thank you for replying.
    I am not very good at all this coding, but I am assuming I should now be doing entering the following:
    =======================
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"width="
    800" height="660"xmlns:comp="
    *" xmlns:fmtComp="fmtComps.*"creationComplete="srcData.send()"
    paddingLeft="
    0" paddingRight="0" paddingTop="0" paddingBottom="0">
    <mx:Script>
    <![CDATA[
    import mx.utils.ObjectProxy; 
    import mx.rpc.events.ResultEvent; 
    Bindable] 
    private var userManualObj:ObjectProxy; 
    private function loadModelData(event:ResultEvent):void
    userManualObj=event.result.UserManual;
    private function readXMLContent(xmlFile:File,objContentView:Object):Array{
    var reportDir:File = File.userDirectory.resolvePath("assets"); 
    var xmlFile:File; 
    var fileStream:FileStream = new FileStream(); xmlFile = reportDir.resolvePath(
    "UserGuide.xml"); 
    if(xmlFile.exists && xmlFile.size > 0)// Checking if the impressions.xml file already exists and the file is not empty
    var stream:FileStream = new FileStream(); 
    var xml:XML = new XML();stream.open(xmlFile, FileMode.READ);
    xml = XML(stream.readUTFBytes(stream.bytesAvailable));
    stream.close();
    ]]>
    </mx:Script>
    <!-- Set up the HTTP service from where we get the source XML data<mx:HTTPService id="srcData"
    url="assets/UserGuide.xml"
    result="loadModelData(event)"/> -->
    <mx:VBox width="100%" horizontalAlign="left" height="100%" paddingBottom="
    0" paddingLeft="0" paddingRight="0" paddingTop="0">
    <mx:TabNavigator width="100%" height="100%"paddingBottom="
    0" paddingLeft="0" paddingRight="0" paddingTop="0">
    <mx:Repeater id="modelsRep" dataProvider="{userManualObj.Product.Model}">
    <mx:VBox label="{modelsRep.currentItem.Name}" width="100%" height="100%">
    <comp:ModelDesc model="{modelsRep.currentItem}"/>  
    </mx:VBox>
    </mx:Repeater>
    <mx:VBox label="Troubleshooting" width="100%" height="100%"paddingBottom="
    0" paddingLeft="0" paddingRight="0" paddingTop="0">
    <comp:Troubleshooting issues="{userManualObj.Product.Troubleshooting.Issue}" />
    </mx:VBox>
    </mx:TabNavigator>
    </mx:VBox></mx:WindowedApplication>
    =======================
    and create and "assets" folder in my user directory placing the XML file in there?
    However when I do all that, I get this error when I try to compile:
      Encountered errors or warnings while building project main.mxml.
        main.mxml: Function does not return a value.
    Any thoughts?
    Many thanks,
    Tim

  • Can I load xml file from SWC without using @embed

    I'm developing a mobile application in which I need to load xml files from File.applicationDirectory. This works great if the xml files are part of the main application swf. But I would like to move these xml files into a SWC so they could be shared across multiple applications.
    Using FlashBuilder 4.5, when a SWC is built, I can specify files to embed in the library that are not assets (Assets Tab of Flex Library Build Path). For various design reasons, I do NOT want to embed the xml files via @embed.
    When the swc is built and I open it up using a zip utility, I see the xml files in there just fine. So they are being bundled with the SWC. But how can I load these files in my main application that does not involve using @embed? When the main application is built, the swc setting for link type is "merged into code".
    I wouldn't expect the application to automatically pull out the xml files from the swc and place them in the File.applicationDirectory on the mobile device. I've tried loading from there just in case but file.exists is false (as expected).
    I've searched the web (and continue to do so) and all the answers seem to be to use @embed. Is there another way?
    Randy

    It's actually a lot easier than you think.
    Just reference the file like any'ol URL using a path relative to the SWC's src directory.
    So if you include the file "assets/xml/some.xml", just use that same string like you would any remote resource.
    For example:
    var loader:URLLoader = new URLLoader( new URLRequest("assets/xml/some.xml"));
    I believe it would also work like this "/assets/xml/some.xml", but I prefer relative paths so the link doesnt break if moved out of the SWC...

Maybe you are looking for

  • Procedure Confirmed with Comparing Dates

    Trying to compare two dates, and there's so many ways I'm just getting a bit confused. I have a date stored in my database in a timestamp field with this format: 2006-03-05 19:13:05 I have a term defined in months (in the database) of how long the ac

  • How to fix audio  of a video captured from DV output of camcorder using Adobe Premiere Elements 8?

    Hello, I purchased Adobe Premiere Elements 8 about one week ago.  I installed it and everything seem to work well in my first project.  I am new at editing videos but I was succesful in testing it by loading an existing video file in avi format from

  • Can you change the Tab Leader in InDesign?

    I have a large text document that I'm working with. I have some tabs set up, nothing special or anything. I need to tab over without the leader on a few lines. Is there a way to change the leader to nothing for just a few lines? Thanks in advance!

  • CD-DVD Reader gives me an eror code 39. It wil not work at all.

    CD-DVD raeder does not work. I have done every thing posssibel and  all I get is error code 39. What do i need to do to get it corected. This question was solved. View Solution.

  • Photosmart 7510 Prints the text offset to the right

    I use  MS Word 2010 and when I print text it appears offset 7 mm to the right. e.g. Left margin set at13 mm starts printing at 20 mm, and Right Margin set at19 mm stops printing at 12 mm. The same offset appears when using other applications e.g. Pub