How do I download/save a local XML file

Hello, I'm developing a game of amateur video on Flex 4, which will be downloadable and execution in the local file system (such as "C:/Games/myGame/myGame.html"). I try to save and load the registry of players in an XML file, also locally (as 'C:/Games/myGame/records.xml).

So far, I was abled to load the file like this:

var loader: URLLoader = new URLLoader();

var request: URLRequest = new URLRequest ("records.xml");

var recordsXml: XML;

try {}

_ loader.load (request);

_ recordsXml = new XML (loader.data);

}

catch (...)

After that, I can then extracts the data perfectly recordsXml. However, I can't figure out what code to use to save changed data. I tried this:

var request: URLRequest = new URLRequest ("records.xml");

Request.Data = recordsXml.toXMLString ();

request.contentType = "text/xml";

Request.Method = URLRequestMethod.POST;

loader.dataFormat = URLLoaderDataFormat.TEXT;

try {}

_ loader.load (request);

}

catch (...)

The code runs without error, but the file is not updated. I tried to record data on a second, empy file records2.xml, but it does not work either.

What should I do? Thank you!

For web applications, you can use the FileReference class. This allows you to

Open a dialog box to the user to load an external file, or save it to their

computer. Here are more details:

http://help.Adobe.com/en_US/AS3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cf8.html

Please note that this only works if the user triggers the action and

through the file dialog box. You can not save or load files without their

knowledge from a web application. A desktop AIR app is different and may

load/save files in the background.

iBrent

Tags: Flex

Similar Questions

  • Cannot load the local xml file from swf

    Hello!

    I have next construction

    (1) in ai3r app to load the SWF by HTMLLoader

    (2) I'm trying to load local xml file in swf. No error and no results.

    Application of AIR-> SWF-> load xml

    When I load xml file site, everything is ok, but when I load just from local file , nothing happens

    and when I load the local file with swf but everything is ok in the browser (firefox)

    for loading xml in a I use the following path: file:///folder_name/xml_file_name.xml

    Help me please!

    Did you write the SWF?  Some sovereign wealth funds will remove errors.

    Why use HTMLLoader?  Who can load it with different security rules.  Content browser often cannot access local content.

  • Read and write to the local XML file

    Hello

    I'm trying to understand how to use the xml files saved locally. My goal is to create an xml file in the repository of the application (which has read/write permissions), add data in this file xml and re - register so that it can be retrieved whenever this is necessary.

    I want to store xml data are farily short; It has the following structure:

    
        x
        x
        x
        x
        x
        x
        x
        x
        x
        x
    
    
    
    ...etc.
    

    I read a few articles about recording and writing in a file like this, but none of them does not seem to work. I hope someone could provide me with the code to do this.

    Thank you.

    Try:

    ///////////////////////////////////////////////////////////////////////

    public public static function Store (name: String, data: String): void

    {

    var file: file = File.applicationStorageDirectory.resolvePath (name);

    var file_stream: FileStream = newFileStream();

    file_stream. Open (file, FileMode.WRITE);

    out of the var : String = '\n';

    output of +=;

    output = output.replace (\n/g, File.lineEnding);

    file_stream.writeUTFBytes (output);

    file_stream. Close();

    }

    //////////////////////////////////////////////////////////////////////////

    public public static function Get (name: String): XML

    {

    var config: XML = null;

    var file: file = File.applicationStorageDirectory.resolvePath (name);

      if (file.exists)

    {

    var file_stream: FileStream = new FileStream();

    file_stream. Open (file, FileMode.READ);

    config = new XML (file_stream.readUTFBytes (file_stream.bytesAvailable));

    file_stream. Close();

    }

    return config;

    }

  • WordPress local xml file to MySQL remote

    I'm developing a site with a WordPress blog php attached using Dreamweaver CS6 on my localhost test server. My php pages contain echoes of private with an average of divs blog posts several per page.

    Here's my problem, when I export my localhost xml file and import the xml file into my WordPress blog hosted remote categories that I posted on site do not have the same #assignment category.

    Example:

    blog/?cat=10for a category on my local blog Exchange assignment, let

    blog/?cat=9on my remote site blog hosted.

    Of course this mess completely echo content will the respective divs on the main site of php pages.

    How can I get either the XML to maintain the cat = # or again to change the assignment of numbers to category at the remote site?

    The reason why I want to develop locally is to be able to demonstrate the site in different locals who do not have access to the internet. In other words I would like my localhost test server mirror site of the actucal on the web site.

    Any suggestions would be greatly appreciated.

    I wonder why the catID order changed remotely. Can you do the following?

    • Perform a full backup of your remote database
    • Export your local DB as a .sql file
    • Only import on your remote DB (full import)

    See if the order remains the same. Let us know how it goes.

    If this does not work, I will guide you in how to change the order to match the list of local.

  • How to extract data from an arbitrary xml file and export it to a CSV friendly?

    Hallo,
    I am facing big problems in the use of XML files. I have a
    application that generates XML files with clusters containing arrays
    and scalars as in the example pasted below. My task is to
    Read it and export the data into a CSV document readable by a human.
    Since I do not know the actual content of the cluster, I need some sort
    Smart VI through the XML looking for berries
    and other data structures for export properly in the CSV file
    format (columns with headers).
    Thank you



    3


    6


    0



    1



    2



    3



    4



    5




    3.14159265358979



    Ciao

    Rather than to get the

    node, you can just go directly to the node since ' one that really interests you. Basically what it means to determine the elements of table how much you have, and it depends on if you have 1 or 2 knots . The rest is just of the child nodes and the next siblings. See attachment as a starting point. The attached XML file is a table 2D (change the .xml extension).

    Notes on the example:

    • I did not close properly references, so it's something you need to do.
    • It is limited to tables 1 d or 2D.
    • I suggest using a control path of the file to specify the input XML file and path of the file/folder control to specify the location of the output file.

  • How can I transfer content from an XML file in a MS SQL database of the stored procedure using LabWindows/CVI SQL Toolkit?

    Hello

    I have a problem to transfer content to an XML file in a MS SQL database through a stored procedure data/fixed. I am able to transfer the content of the file using method...

    HSTMT = DBPrepareSQL (hdbc, EXEC usp_InsertReport " ... ");

    resCode = DBExecutePreparedSQL (hstmt);

    resCode = DBClosePreparedSQL (hstmt);

    ... but in this case, I am not able to read the return value of the stored procedure.

    I tried to follow the example of the stored procedure in the help documentation (DBPrepareSQL), but I miss a xml data type?

    No idea how to solve my problem?

    Cake of KR

    DianaS salvation,

    Thanks for your comments. During this time I found another way which fullfill my needs:

    resCode = DBSetAttributeDefault (hdbc, ATTR_DB_COMMAND_TYPE, DB_COMMAND_TEXT);

    sprintf (sz_SqlStatement, "DECLARE @TESTID INT EXEC @TESTID = usp_InsertReport ' SELECT 'RetVal' %s = @TESTID", sz_Buffer ");
    HSTMT = DBActivateSQL (hdbc, sz_SqlStatement);

    While ((resCode = DBFetchNext (hstmt)) == DB_SUCCESS)

    {

    / * Enter values in the record. */

    resCode = DBGetColInt (hstmt, 1, & s32_TestId);
    }

    resCode = DBDeactivateSQL (hstmt);

    sz_Buffer is the content of the XML file.

    Cake of KR

  • How to use resource element in the xml file in the workflow?

    Good afternoon

    In my workflow, I put a parameter of the attribute with the element of resource type and the value of the attribute is an xml file.

    And I had a problem with xml files in my workflow, I would like to use the information in the xml file to store in the variable...

    Example: in the xml file, I put some information about the number of VLAN ID, and in my script task, I would like to know how is used with myvariable.portgroup [0].spec.vlanId?

    Best regards.

    Like this:

    var myXml = new XML(resource.getContentAsMimeAttachment().content);
    

    You can then access your nodes like this:

    myXml.node.subnode

    Google for e4X to get the syntax complete.

  • RSS feeds save in the xml file in the device memory

    Hello

    I'm in the analysis of an RSS feed with SAX parser. Now, I want to record the first RSS an xml file in the memory of the device or on the SD card. Can someone guide me through this process

    To write in an XML rss content, start by creating the file with the extension ".xml" with the help of the FileConnection API, then write content (rss data) in the XML file.

    You can use code below to write the content in the file. We must give the path as a string & content in byte format.

    public boolean writeFile(String path, byte[] data)
        {
            javax.microedition.io.Connection c = null;
            java.io.OutputStream os = null;
            try {
                c = javax.microedition.io.Connector.open("file:///" + path, javax.microedition.io.Connector.READ_WRITE);
                javax.microedition.io.file.FileConnection fc =
                        (javax.microedition.io.file.FileConnection) c;
                if (!fc.exists())
                    fc.create();
                else
                    fc.truncate(0);
                os = fc.openOutputStream();
                os.write(data);
                os.flush();
                return true;
            } catch (Exception e) {
                return false;
            } finally {
                try {
                    if (os != null)
                        os.close();
                    if (c != null)
                        c.close();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    
  • How to create ViewObject to generate the xml file?

    Hello everyone...

    People, I would like to know if it is possible to create a ViewObject to generate an xml file.
    In other words, I have a database table and I need to generate an xml file based on this table.

    Someone has already done it?

    The ADF swing.
    JDeveloper Studio 11.1.1.4.0.

    Hello

    Try this link

    Generate the xml file based on the java oracle table using jdeveloper 10 g

  • How to add URL links in the XML file?

    Hello

    I have a problem with adding the URL links to the power of lightning. I use the XML file to call images, then the corrsponding links. Images are called correctly but when I try to add a link I do not receive the links, but rather to get the anchor HTML text tags. I use escape XML characters to escape HTML tags, but the results are not what I need.

    I use the following code:

    < preview = "miniature large.jpg" thumb = "thumb.jpg" > "
    < title > <! [CDATA [Financial Services]] > < / title >
    < discription > <! [CDATA [& lt; a href = & quot; ]] http://www.google.ca "> Google < / a > " [[ ]] > < / discription >
    < / thumbnails >

    ---------------------------

    Output:

    Images are displayed correctly, but instead get the links, I get following message:

    " < a href =" http://www.Google.ca "> < /a > Google .

    I need to know what I'm doing wrong. I use the proper way to add links or not?

    Thanks for your time.

    Use tags html directly inside CDATA - after all, what CDATA is for.

  • How to get the number of a xml file in flash?

    Hello

    It comes to my XML file

    <? XML version = "1.0"? >

    < ArrayHolder >

    < level1 > '1', '1', '1' < / level1 >

    < level2 > 2,2,1,2,2 < / level2 >

    < level3 > 1,3,3,3,1 < / level3 >

    < / ArrayHolder >

    I want to store level1 not in 'levelArray '.

    Thank you

    JaxNa

    you always have a quote but once it is fixed, divide each value of the node on the commas and then loop in the table pouring each element to a number.

  • How to reference a value in an XML file

    Hey guys!  I have a valid XML structure is the following:

    <app>
         <settings>
              <setting name="defaultModuleSlug" value="apples"></setting>
              <setting name="defaultPageSlug" value="oranges"></setting>
         </settings>
    <app>
    

    XML info is an application object called application.config.

    So, how do you refer to the variable defaultPageSlug?  I know that I can use:

    application.config[ 'app' ][ 'settings' ].xmlChildren[ 2 ].xmlAttribute[ 'value' ]
    

    However, I would like to be able to reference the implementation by its name (defaultPageSlug) attribute and not assuming that it is the 2nd element of this node.  Can anyone help?

    Nevermind, I guess I can use XPath.

  • PB to download the different domain xml file

    Hello

    I want my flash site to convert currencies.
    This is why I want to get the rates of Exchange from the internet.

    Initially, I wanted to do this by using web services, but the free one I found:
    http://www.webservicex.com/CurrencyConvertor.asmx?op=ConversionRate
    does not work properly (loading problems?)

    So I decided to use another way by getting my rate from the RSS file:
    http://www.CurrencySource.com/RSS/EUR.XML

    Everything is ok, I had the rates I am interested in the analysis of the RSS.

    But everything is ok when I test locally, when I put my file on my hosting server, rates cannot be recovered more, it seems that if there is a connection problem.

    Is there a security problem? Can someone help me?

    I've heard of cross-domain policy file, but I can not put such a file on a server that I do not know
    i.d., is to put the file on the server hosting http://www.currencysource.com/rss/EUR.xml, I can't apply this...

    Thanks for your help

    Thanks Aaron!

    That's exactly what I did:
    http://KB.Adobe.com/selfservice/viewContent.do?externalId=tn_16520&sliceId=2
    ... and it works ;)

  • How to mount an image of an xml file in the cell of CC2015 graphics

    Hello

    I'm having a very difficult time, editing of an image that is imported with XML graph the table cell. Before graphics power cell was fine but now I can't he mounted. The image is imported into the cell, but each image is placed in the same height created the cell (in fact).

    So, I have to mention that the problem is related to the import of xml for classified ads. Therefore, the page layout is not prepared but generated with import. Image in the cell is necessary in this car design solution.

    I don't know I'm missing something... Please, open your eyes.

    Thank you!!!

    Marko

    Hi Marko,

    Maybe you can avoid the graphics cells, if you place the images in table cells.

    HM, we could try pre-fill a cell text with the content must match a white-space character and after that place the image in the first cell insertion point (as in the former with CC 2014 and before workflow).

    Uwe

  • How can I download HZ Tables only HTML file?

    Hi guys,.
    I have download all the schema files HTML as AP, AR, GL of eTRM on my computer but when I'm looking for the CAW or HZ, I find not a single html file, its show me a table.i want a single file with all the tables table HZ and I use in my net off time for r ' D.kindly help me such CAW file exist in eTRM.

    Kind regards
    Shakeel Khan

    Shakeel,

    You can find the HZ tables under schema AR (click on 'Static HTML files' > select 'AR' under the 'Product' and click on submit) and download "AR_Tables.html", you should find all the tables of HZ in this file.

    Thank you
    Hussein

Maybe you are looking for