Loading XML file from EAR root ?

I would like to be able to load/read an XLM file stored in the EAR root (just aside JARs and WARs). That way it will be easy to find and modify the file.
But I can't read it :-/
Is it possible to do so, or am I just doing crap ?

What are you doing wrong? You're using a Transformer, which expects to be given an XSLT document. If you want to make a DOM from that then you should use a DocumentBuilder, or you could use a SAXParser if you just want to extract the data from the XML file as you read it.

Similar Messages

  • 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.

  • 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...

  • Loading XML files from URL

    Hi.
    My PL/SQL procedure loading xml files from oracle logical directory ("c:\temp") and inserting values into columns of the table. I use XSU with procedure:
    create or replace procedure insProc(xmlDoc IN CLOB, tableName IN VARCHAR2) is
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    begin
    insCtx := DBMS_XMLSave.newContext(tableName); -- get the context handle
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); -- this inserts the document
    DBMS_XMLSave.closeContext(insCtx); -- this closes the handle
    end;
    For translate xml document to CLOB, I use :
    CREATE OR REPLACE function getdocument(
    p_directory in varchar2,
    p_filename in varchar2)
    return clob
    is
    l_bfile bfile;
    l_clob clob;
    begin
    l_bfile := bfilename(p_directory, p_filename);
    dbms_lob.open(l_bfile);
    dbms_lob.createtemporary(l_clob, true, dbms_lob.session);
    dbms_lob.loadfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile));
    dbms_lob.close(l_bfile);
    return l_clob;
    end getdocument;
    I didn't have problem with this procedures. But now i want load my xml files from another computer (i want use URL, not oracle logical directory).
    How can i do it, using standart PL/SQL methods?

    Since you are parsing the XML what prevents you from delaying your requests for the image URL's? You can just as well add the image URL's to some kind of collection and load them after you have processed all the text content.

  • 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

  • Loading XML file from classpath...

    Hello all.
    Can anyone help me with loading an XML file from the classpath?
    The XML I need to load looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <QueueDispatcher>
      <QueueConfigEntry>
        <DataSource>
          <TableName><![CDATA[WPOrder]]></TableName>
        </DataSource>
        <DataSink>
          <JMSQueueName><![CDATA[OTL_WPORDER]]></JMSQueueName>
        </DataSink>
      </QueueConfigEntry>
    </QueueDispatcher>I'm trying to load the file with the following code:
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    InputStream  input = this.getClass().getResourceAsStream("/QueueDispatcherConfig.xml");
    StreamSource streamSource = new StreamSource(input);
    Transformer  transformer  = transformerFactory.newTransformer(streamSource);
    ....All I get at the moment is an exception:
    javax.xml.transform.TransformerException: stylesheet requires attribute: version
    Any ideas what I'm doing wrong?
    Thanks in advance

    What are you doing wrong? You're using a Transformer, which expects to be given an XSLT document. If you want to make a DOM from that then you should use a DocumentBuilder, or you could use a SAXParser if you just want to extract the data from the XML file as you read it.

  • Loading External Files From SWF Root

    Hi All,
    I do not know anything about flash.  I have been provided with some flash movies/apps to include in a web design that I am doing.  These flash movies load an external xml file.
    This is failing.
    The problem appears to be that when the flash movie goes to load the file using a relative directory path, it starts at the very root of the web directory, where the main jsp file is, instead of the where the .swf file is located.
    For example, say my website is www.mywebsite.com/mysite.jsp and I have stored the flash in a directory similar to /mywebsite.com/flash/movie1/movie1.swf.
    When the movie goes to play, I am getting a 404 error in firebug because the flash movie is trying to load the external xml from /mywebsite.com/file.xml instead of /mywebsite.com/flash/movie1/file.xml.
    How can this be corrected?  Is there a way for the flash application to use the .swf root directory instead of the .jsp file root directory?
    I hope this made sense.  Good chance it doesn't. 

    When you load the Flash file into a web page, the web page becomes its frame of reference for loading other content.  So to fix this situation you should either relocate things to where the Flash file lives in the same directory as the web page that loads it, or retarget the files that the Flash file is loading as if it were in the web page's folder (using absolute paths should guarantee correct targeting).

  • Loading XML file from desktop

    Hi Expects!
    I want to try out loading a XML file in BI 2004s. is it possible to load an existing file from the desktop to BI? or does it have to be 'pushed' by an external system only?
    We have created webservice datasource, but we cannot assign a source of data to this, as no such option is available.
    Thanks in advance
    Sushmita

    You may wish to have a look below-
    <b>Data Transfer Using Web Services</b>
    http://help.sap.com/saphelp_nw04s/helpdata/en/71/421640033ae569e10000000a155106/frameset.htm
    <b>Creating a Web Service for Loading Data</b>
    http://help.sap.com/saphelp_nw04s/helpdata/en/ab/0709407448c442e10000000a1550b0/content.htm
    Hope it Helps
    Chetan
    @CP..

  • Problem with loading XML file from directory.

    Hello everyone.
    *1)* I have directory defined by DBA. I have read, write privileges. I can read file from this directory using UTL_FILE, I can create file in this directory using UTL_FILE. I tried many times and it does not seem to be any problems.
    *2)* I have very simple XML table (with just one column of xmltype). I can insert into this column using:
    insert into temp_xml values (
    Xmltype ('<something></something>')
    *3)* When executing
    insert into temp_xml values (
    Xmltype (
    bfilename('XML_LOCATION', 'sample.xml'),
    nls_charset_id('AL16UTF8')
    I'm receiving an error:
    Error report:
    SQL Error: ORA-22288: file or LOB operation FILEOPEN failed
    ORA-06512: at "SYS.DBMS_LOB", line 523
    ORA-06512: at "SYS.XMLTYPE", line 287
    ORA-06512: at line 1
    22288. 00000 - "file or LOB operation %s failed\n%s"
    *Cause:    The operation attempted on the file or LOB failed.
    *Action:   See the next error message in the error stack for more detailed
    information. Also, verify that the file or LOB exists and that
    the necessary privileges are set for the specified operation. If
    the error still persists, report the error to the DBA.
    *4)* Previously I was receiving more descriptive errors like permission denied, file not exists etc. This time there is no clear description apart from "file or LOB operation %s failed\n%s". I'm sure I can access this file in this directory (I used UTL_FILE to dbms_output the content).
    Any help would be greatly appreciated.
    Regards
    Marcin Jankowski

    Hi Marcin,
    Welcome to the forums.
    One very important thing with Oracle XML : please always give your database version, all four digits (e.g. 10.2.0.4).
    Does the directory resides on the same machine as the database? Which OS?
    Does any of the following work ?
    DECLARE
       v_lob   CLOB;
       v_file  BFILE;
    BEGIN
       v_file := BFILENAME('XML_LOCATION','sample.xml');
       DBMS_LOB.createtemporary(v_lob, true);
       DBMS_LOB.fileopen(v_file);
       DBMS_LOB.loadfromfile(v_lob, v_file, DBMS_LOB.getlength(v_file));
       INSERT INTO temp_xml VALUES( xmltype(v_lob) );
       DBMS_LOB.fileclose(v_file);
       DBMS_LOB.freetemporary(v_lob);
    END;
    DECLARE
       v_lob   CLOB;
    BEGIN
       v_lob := DBMS_XSLPROCESSOR.read2clob('XML_LOCATION', 'sample.xml', nls_charset_id('AL16UTF8'));
       INSERT INTO temp_xml VALUES( xmltype(v_lob) );
    END;
    /

  • Load XML File From Repository

    Assume you declare a process variable of type XML. Is it possible using the Set Value service to fill this variable with an XML file that is in the repository?
    I was thinking something like this might work, but it doesn't seem to
    Location Expression
    /process_data/xml_data /Stuff/data/data.xml

    You would have to use a Read Content from Repository service to get it out then you can use the SetValue to manipulate as you see fit. The XPath expression cannot access the repository directly.

  • Load XML file to XMLTable from FTP site Problem Oracle9i Release 9.2.0.7.

    Hi,
    I was wondering if it is possible to load XML file from FTP address directly to XMLType Table?
    Can someone help me?
    For example I have ftp site "ftp://test" and on this site I have file "file.xml"
    and I would like to load "file.xml" to table "xml_tab" ?
    I tried to use "load_xml" procedure and set DIRECTORY "xml_dir" to 'ftp://test' but I get this error
    exec load_xml(p_dir=>'XML_DIR', p_filename=>'file.xml');
    ERROR at line 1:
    ORA-22288: file or LOB operation FILEOPEN failed
    The network path was not found.
    ORA-06512: at "SYS.DBMS_LOB", line 504
    ORA-06512: at "P.LOAD_XML", line 8
    ORA-06512: at line 1
    Procedure looks like this:
    (p_dir IN VARCHAR2,
    p_filename IN VARCHAR2) AS
    l_bfile BFILE := BFILENAME(p_dir, p_filename);
    l_clob CLOB;
    BEGIN
    DBMS_LOB.createtemporary (l_clob, TRUE);
    DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
    DBMS_LOB.loadfromfile(l_clob, l_bfile, DBMS_LOB.getlength(l_bfile));
    DBMS_LOB.fileclose(l_bfile);
    INSERT INTO xml_tab (
    id,
    filename,
    xml
    VALUES (
    xml_tab_seq.NEXTVAL,
    p_filename,
    XMLTYPE.createXML(l_clob)
    COMMIT;
    DBMS_LOB.freetemporary (l_clob);
    END;
    I have tried also with this
    select xdburitype('ftp://test/file.xml').getCLob() from dual;
    but i get error
    ERROR:
    ORA-31001: Invalid resource handle or path name "ftp://test/file.xml"
    Can you pleeeeeeas show me a way to do this, thanks ???

    This will not work.. Ypu cannot use FTP to 'PULL' a document into the database. (Yes I know there's a placeholder for an FTPURITYPE() but it was never implemented).
    However you can use an FTP client to PUSH content into the XML DB repository. If the content is schema based XML associated with a known (registered) XML schema the content of the file will automatically be stored in the default table associated with the root element of the file. If the content is not associated with an known XML schema you can then use xdburitype to read the resource that was created when the document was uploaded into the repository

  • Import xml file from server to itab

    Hi all,
    I have a little issue loading data from xml file in server into my itab.
    With my file in local (C:\example\example.xml) works fine, but if try this with the same file in the server (e:\example\example.xml) dont work. This is my code resume.
    TYPES: BEGIN OF TY_TAB,
    NAME TYPE STRING,
    VALUE TYPE STRING,
    END OF TY_TAB.
    DATA: ITAB TYPE STANDARD TABLE OF TY_TAB,
    WA TYPE TY_TAB.
    * Nombre del fichero
    DATA: NOMBREFICHEROXML LIKE IBIPPARMS-PATH,
    * data XML
    DATA: LCL_XML_DOC TYPE REF TO CL_XML_DOCUMENT,
    V_SUBRC TYPE SYSUBRC,
    V_NODE TYPE REF TO IF_IXML_NODE,
    V_CHILD_NODE TYPE REF TO IF_IXML_NODE,
    V_ROOT TYPE REF TO IF_IXML_NODE,
    V_ITERATOR TYPE REF TO IF_IXML_NODE_ITERATOR,
    V_NODEMAP TYPE REF TO IF_IXML_NAMED_NODE_MAP,
    V_COUNT TYPE I,
    V_INDEX TYPE I,
    V_ATTR TYPE REF TO IF_IXML_NODE,
    V_NAME TYPE STRING,
    V_PREFIX TYPE STRING,
    V_VALUE TYPE STRING,
    V_CHAR TYPE CHAR2.
    NOMBREFICHEROXML = 'E:\example\example.xml'.
    CREATE OBJECT LCL_XML_DOC.
    CALL METHOD LCL_XML_DOC->IMPORT_FROM_FILE
    EXPORTING
    FILENAME = NOMBREFICHEROXML
    RECEIVING
    RETCODE = V_SUBRC.
    IF V_SUBRC EQ '0'.
    V_NODE = LCL_XML_DOC->M_DOCUMENT.
    CHECK NOT V_NODE IS INITIAL.
    V_ITERATOR = V_NODE->CREATE_ITERATOR( ).
    V_NODE = V_ITERATOR->GET_NEXT( ).
    WHILE NOT V_NODE IS INITIAL.
    CASE V_NODE->GET_TYPE( ).
    WHEN IF_IXML_NODE=>CO_NODE_ELEMENT.
    V_NAME = V_NODE->GET_NAME( ).
    WHEN IF_IXML_NODE=>CO_NODE_TEXT OR
    IF_IXML_NODE=>CO_NODE_CDATA_SECTION.
    *text node
    V_VALUE = V_NODE->GET_VALUE( ).
    MOVE V_VALUE TO V_CHAR.
    IF V_CHAR <> CL_ABAP_CHAR_UTILITIES=>CR_LF.
    WA-NAME = V_NAME.
    WA-VALUE = V_VALUE.
    APPEND WA TO ITAB.
    CLEAR WA.
    ENDIF.
    ENDCASE.
    *advance to next node
    V_NODE = V_ITERATOR->GET_NEXT( ).
    ENDWHILE.
    WRITE:/ 'file ok'.
    ELSE.
    WRITE:/ 'file ko'.
    Anyone can help, or tell me a easy way to load xml file from server to my itab that works with my old sap 4.7.
    thanks
    Edited by: DIEGO_GT on Nov 18, 2011 12:04 PM

    Hi Diego.
    Next time try to search in [www.sdn.sap.com] first.
    See the following example: [http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table]
    Regards.
    Rafael Rojas.

  • Loading XML file

    Hi All,
               How to load xml file from backend.
              i have 5 xml files in databse. i need to get the xml files from database sequentially .means i need to get in a for loop.
    how can i do this.
    any one can help?
    thanks
    Raghu

    is your front end in Flex?
    Sammi

  • Loading XML file to BI 7

    Hi,
    I have a requirement to load XML file from Application server to BI 7. Most of the documents I saw online are related to BW 3.X.
    does any one have good examples of how this can be done in BI 7.
    thanks

    hi
    check the SAP documentation for loading XML file to BI
    http://help.sap.com/saphelp_nw70/helpdata/en/fe/65d03b3f34d172e10000000a11402f/frameset.htm

  • Loading xml file to javascript

    hi,
    i want to load xml file from javascript and to get the tree structure dynamically..
        xml file is:
          <?xml version="1.0"?>
    <personal>Personal Details
            <name>Premshree Pillai</name>
            <***>male</***>
            <websites>Websites
                    <ws1>http://www.qiksearch.com</ws1>
                    <ws2>http://premshree.resource-locator.com</ws2>
            </websites>
    </personal>
      pls send me steps to get the tree structure
    thanks

    hi,
      In google i am gettting only static tree...
      i want dynamic tree structure , where nodes are coming from xml file
    dynamically

Maybe you are looking for