Load XML and edit
Hi I am new to Flex and AS3 but I have some experience with
XML, XSLT, XPATH, VB etc..
I am having trouble just loading the XML. How do I load an
external XML file so I can edit it?
This is what I have so far:
<mx:Script>
<![CDATA[
var myxml = 'xml/request.xml';
XML.ignoreWhitespace = true;
var xml:XML = new(myxml);
]]>
</mx:Script>
I recieve an error:
"TypeError: Error #1007: Instantiation attempted on a
non-constructor."
Thanks in advance
I did that in my application for loading a XML file. I hope
it helps you :)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:custom="*"
layout="absolute"
horizontalScrollPolicy="off"
backgroundAlpha="0"
creationComplete="init();"
>
<mx:Script>
<![CDATA[
import mx.controls.Image;
import flash.display.*;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
public function init():void
var loaderSkin:URLLoader = new URLLoader();
var requestSkin:URLRequest = new URLRequest("XML/skin.xml");
loaderSkin.load(requestSkin);
loaderSkin.addEventListener(Event.COMPLETE,
finDuChargementSkin)
public function finDuChargementSkin ( event:Event ):void {
var skin:XML = new XML (event.target.data)
\\put your code here
]]>
</mx:Script>
<mx:Label id="myLabel" width="1000" fontWeight="bold"
fontSize="12"/>
</mx:Application>
Similar Messages
-
Is there a way to load an xml file and parse the tags as we do in javascripts in java?
i want to write a generic xml parser.
what all should i know before starting.
i choose java as my development language.Is there a way to load an xml file and parse the tags
as we do in javascripts in java?Yes?
>
i want to write a generic xml parser.There is one built into Java or you can use JDOM or Dom4J.
>
what all should i know before starting.Difficult to say without knowing what you are doing but the Java tutorial is a good starting point.
i choose java as my development language. -
Can I create an xml and edit in Creator2??
hat is my problem....
What you mean?
Authoring a XML inside JSC IDE or make a program which manipulates a XML?
If what you want to manipulate a XML file, you can use jdom or dom4j.
If you need a page which edits an XML file, you can use JSF components for presentantion and use jdom / dom4j to get and put data.
Regards. -
Java and XML :: Unlocking, editing and locking an XML file using JAVA
I need to develop a form with Address field , When i enter address information and submit the form it needs to generate an
XML file for furthur processing.
Now my problem is :
When i want to edit the address....after submitting the form by entering the address information, it should unlock
the XML and edit the XML and then lock it.
How can i achive programatically, unlocking an XML file, editing the file, and locking it?.
Thanks,
Maruthi.There's a FileLock class, you know, in the java.nio.channels package. However before you start using it you should read its API documentation carefully including statements like " Whether or not a lock actually prevents another program from accessing the content of the locked region is system-dependent and therefore unspecified".
Personally I would say that if you need to synchronize access to this XML file, you should consider changing your design to use something that supports locking a bit better, like a database. Or by writing a server that encapsulates the XML file and accepts requests to read it and update it, serializing those requests appropriately. -
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
ArifuddinHi;
Pelase review below which could be helpful for you
XML Publisher Report Issues, Recommendations and Errors [ID 862644.1]
Regard
Helios -
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. -
Loop movie, but load XML once
Background:
I am tasked with building a vertical news scroller that reads
from an xml file and loops indefinitely.
Problem 1:
I have figured out how to scroll static text and I am now
working on loading the xml which I also have done. The problem I am
having with loading the xml is that if the movie loops, it is
loading the XML each instance of the loop. How can I load the XML
only on the initial load and still loop the movie?
Problem 2:
When working with static text, scrolling is simply a matter
of doing a motion tween. When working with XML, the data will not
be a fixed length, so doing a motion tween will have 2 problems.
First, the original text object will have a fixed height which will
either have blank space when the XML returns less than enough to
fill it, or will have hidden text when the XML returns more that it
can hold. Can I dynamically adjust the height of a text object to
fit the text that has been put into it? Once I figure out how to
dynamically change the height we have the second problem. If the
tween was built to scroll 10 records over 200 frames and the XML
now returns 100 records, the scroll will be 10 times too fast. Can
I dynamically adjust how many frames the tween will operate
over?1. You can keep the XML in a variable and use an if/else to
determine if the XML is loaded.
var myXML:XML
// later
if(!myXML){
// call function or class that loads XML and assigns loaded
XML to the variable myXML
2. You can make dynamic TextField autosized AND multilined
(autoSize and multiline text filed properties) - it will adjust
text height depending on the content - width will not be affected.
Since the scrolling is an indefinite motion in this case, I
am not sure tweening is the best approach. Perhaps a better and
more controllable solution would be to write your own function
(class) that will perform the scroll. -
hi all
It would be appreciated if any one let me know how to edit
bitmap which is imported in flash using xml and save the edited
bitmap back to xml in flash.
Is it posible to save the bitmap data in flash?
thanks in advanceYes you can... but like I said before you need to upload the
data from the changes you make to a server.
In terms of the solution... its unlikely that you'll find one
specifically for your needs. You will have to learn whatever you
don't know how already and maybe adapt some existing examples to
your needs.
To change the visual state of a movie clip... you just do all
the regular things that you want to do to it using flash... scale,
rotation, drawing API , textfields etc in actionscript. If you
don't know how to how to do that stuff, then you need to learn that
first. That's basic actionscript.
You can capture the visual state of a movieclip using the
BitmapData class. That includes a loaded jpeg. You can also
manipulate bimatp data using the same class. You should read up on
that if you don't know how to use it or check out the examples
below for uploading info.
For uploading to the server:
Here's an as2 solution that took 15 secs to find using
google:
http://www.quasimondo.com/archives/000645.php
If you're using as3, google search for "jpeg encoder as3" and
look through that info. There are also historical answers in the
forums here related to this type of thing that might help as
well. -
OWB11gR2 - simple and easy way to load XML formatted data into db tables?
Hi,
we're currently trying to load table data stored in XML files into our datawarehouse using OWB 11gR2.
However, we're finding this is not quite as trivial as loading flat files...
Most postings on this forum points to the blog-entry title "Leveraging XDB" found here (http://blogs.oracle.com/warehousebuilder/2007/09/leveraging_xdb.html).
This blog also references the zip-file owb_xml_etl_utils.zip, which seems to have disappeared from it's original location and can now be found on sourceforge.
Anyway, the solution described is for OWB 10g, and when trying to import experts from the zip-file etc. we end up not being able to run the "Create ETL from XSD" expert, as the 11gR2 client is different from the 10g and does not have the Experts menu et.al.
Also, this solution was published over 3 years ago, and it seems rather strange that importing XML-formatted data should still be so cumbersome in the newer warehouse builder releases.
The OWB 11gR2 documentation is very sparse (or rather - quite empty) on how to load XML data, all it has is a few lines on "XML Transformations", giving no clue as to how one goes about loading data.
Is this really the state of things? Or are we missing some vital information here?
We'd have thought that with 11g-releases, loading XML-data would be rather simple, quick and painless?
Is there somewhere besides the blog mentioned above where we can find simple and to the point guidelines for OWB 11gR2 on how to load XML-formatted data into Oracle tables?
Regards,
-Haakon-Yes it is possible to use SQL*Loader to parse and load XML, but that is not what it was designed for and so is not recommended. You also don't need to register a schema, just to load/store/parse XML in the DB either.
So where does that leave you?
Some options
{thread:id=410714} (see page 2)
{thread:id=1090681}
{thread:id=1070213}
Those talk some about storage options and reading in XML from disk and parsing XML. They should also give you options to consider. Without knowing more about your requirements for the effort, it is difficult to give specific advice. Maybe your 7-8 tables don't exist and so using Object Relational Storage for the XML would be the best solution as you can query/update tables that Oracle creates based off the schema associated to the XML. Maybe an External Table definition works better for reading the XML into the system because this process will happen just once. Maybe using WebDAV makes more sense for loading XML to be parsed (I don't have much experience with this, just know it is possible from what I've read on the forums). Also, your version makes a difference as you have different options available depending upon the version of Oracle.
Hope all that helps as a starter.
Edited by: A_Non on Jul 8, 2010 4:31 PM
A great example, see the answers by mdrake in {thread:id=1096784} -
Weblogic-ejb-jar.xml generation and editing question with JEE5 / EJB3
Since EJBGen only works with EJB 2.1, is there a way to auto-generate weblogic-ejb-jar.xml when using a JEE5 ejb module?
In the tooling like OEPE 11g, an EJB3 project will generate an empty deployment descriptor weblogic-ejb-jar.xml file if you mark it that way in the wizard, but it doesn't populate it with any values.
Is the weblogic-ejb-jar.xml file is created/edited by hand, do the settings like this example still work or even make sense given the changes in the spec between 2.1 and 3.0?
<weblogic-enterprise-bean>
<ejb-name>HelloUser</ejb-name>
<stateless-session-descriptor>
<pool>
<max-beans-in-free-pool>50</max-beans-in-free-pool>
<initial-beans-in-free-pool>10</initial-beans-in-free-pool>
</pool>
<stateless-clustering>
<home-is-clusterable>True</home-is-clusterable>
<home-load-algorithm>round-robin</home-load-algorithm>
<stateless-bean-is-clusterable>True</stateless-bean-is-clusterable>
<stateless-bean-load-algorithm>round-robin</stateless-bean-load-algorithm>
</stateless-clustering>
</stateless-session-descriptor>
<enable-call-by-reference>true</enable-call-by-reference>
</weblogic-enterprise-bean>
........Hi,
For a JEE5 EJB module, rather than using EJBGen, you can use WLS specific annotations for configuring common settings. If you follow the link below, you can see a list of supported EJB annotations. Disregard the fact that the documentation section title is WebLogic Kodo Annotations. That is incorrect and I've filed a bug for it.
http://edocs.bea.com/wls/docs103/ejb30/annotations.html#wp1438036.
Unfortunately, we don't yet support setting all weblogic-ejb-jar.xml configuration values via annoations so in some cases a weblogic-ejb-jar.xml is still required.
You can hand edit your weblogic-ejb-jar.xml and the example you posted below should work fine.
- Matt -
XML Creating, editing and saving! ;D
Hey!
So, here's what I want to do:
When the users loads the Flash File, I want the ActionScrip to create an XML file that says:
<id="000000" tutorial="no" name="000000" coins="3000">
Now, I want the flash file to see that the user hasn't completed the tutorial.. and if it says NO it should load: tutorial.swf
Then, once the tutorial.swf end, after the final button is clicked I want it to edit the XML file so that tutorial="no" is replaced with tutorial="yes" and it loads 'user.swf' And when the FlashFile is reloaded, it checks that the tutorial="" says yes, and it skips out tutorial.swf and it goes straight to user.swf..
If it's not clear I'll show it below:
Load tutorialcheck.swf
If tutorial="" says no load tutorial.swf
If tutorial="" says yes load user.swf
Load tutorial.swf
If tutorial is complete, on final button click edit XML and say tutorial="yes", then load user.swf
Thanks!Hi
Although not directly related to your problem, you can find an example of loading, editing and saving xml here.
I have created a demo of Loading,Editing & Saving XML To/From Flash.
You can find the Demo here http://demo.thefeldkircher.org/flashxml/xmlles/xmlls.htm
You can find the How-To here http://blog.thefeldkircher.org/?p=262
Hope it helps. -
How open and edit the coherence.xml file?
How can I open and edit the coherence.xml file?
I cannot find the coherence.xml file in the coherence.jar package.
Thank you,
JuneIf you are intent on changing the coherence.xml file, then you could use the JAR command (that comes with Java) to extract the coherence.xml file from coherence.jar and the later repackage the coherence.jar file using the udpated coherence.xml file, e.g.:
C:\java\opt\coherence-331\lib>jar -xvf coherence.jar tangosol-coherence.xmlextracted: tangosol-coherence.xml>
Instead of using JAR, on Windows you can associate the .JAR, .WAR and .EAR extensions with WinZip and use it to access / modify the contents of JAR files.
However, the suggested approach is as follows, and does not include any changes to the tangosol.jar file:
The tangosol-coherence-override-dev.xml file can be found in the coherence.jar file. After editing this file (in this case to define a unique value for the port system-property value for the multicast listener), save the file and add it to the server's classpath. When the server is executed, the values in the tangosol-coherence-override-dev.xml file will override any corresponding settings in the tangosol-coherence.xml file.Peace,
Cameron Purdy | Oracle Coherence -
How get and edit xml code of BI Publisher Report
Hi to all,
I need to do some costumization to one BI Publisher report. Investigating I found a solution to do my costumization. However this requieres edit the xml code. Can you please let me know how can I get and edit this code?
Thanks in advance
regards
Danielobiee / ebs .... ?
Investigating I found a solution to do my costumization. However this requieres edit the xml code.
no need edit seeded code (it's for SR)
your steps:
- get seeded code
- edit
- create custom report
Can you please let me know how can I get and edit this code?
for ebs you can look xml publisher responsibility, find by code -
someone please help me! I just traveled to hong long and the minute I arrived something wrong was happening with my photos, I can't take any new photos because if I did they either get repeated or just be shown as grey pictures and when I try to upload one to a photo editing app it says "error cannot Load photo" and the same happens in twitter and Facebook! this has been found on for Like more than a week now, even when I want to set a picture as my profile picture in man it ends up zooming the picture way more than how I chose it in the border,, I would like to be able to take good photos again, any help?
1. You did not get an error message telling you that your iPhoto library was getting full. You got a message telling you that your HD was getting full, right?
OS X needs about 10 gigs of hard drive space for normal OS operations - things like virtual memory, temporary files and so on.
Without this space your Mac will slow down as the OS hunts for space on the disk, files will be fragmented, also slowing things down, apps will crash and the risk of data corruption - that is damage to your files, photos, music - increases exponentially.
Your first priority is to make more space on that HD. Nothing else can be done until you do.
Purchase an external HD and move your Photos and Music to it. Both iPhoto and iTunes can run perfectly well with the Library on an external disk.
Your Library has been damaged from being run on an overfull disk.
How much free space on it now? -
Loading XML using a custom class and accessing it from other classes?
I began with a class for a movie clip rollover function
FigureRollOver. It works marvellously. Three things happen:
1) it loads XML from a file "mod1_fig1.xml" and uses another
class, XMLMember, to retool the scoping of the XML so that I can
get at it
2) an onload call inside of XMLMember calls the myOnLoad
function and transfers the XML into an array.
3) so long as the array is finished building, rolling over a
movie clip attaches a new movie clip with the rollover text in it.
But I don't want all those functions in one because I need it
to be more dynamic, starting with being able to load any old xml
file instead of just "mod1_fig1.xml", plus it seems like
overbuilding to have all of that in one class, so I've separated
out the loading of the XML and building of the array into its own
class, FigureXMLLoader. FigureRollOver is then left to just attach
the rollover with text in it, extracted from the array built by the
new class.
Problem is, though the array builds inside FigureXMLLoader, I
can't figure out how to make it available outside the class. I know
that I'm constructing things in the wrong order, and that the array
needs to be somehow built inside the class function to be
available, but I can't figure out how to do that. A cruddy
work-around is to put a function call at the end of the building of
the array, which calls yet ANOTHER function on the main timeline of
my .swf to put the array I've just built into a new variable. This
works, but it's messy. It seems like I should be able to have one
line of script in the .swf that generates an array on the main
timeline (or just a public array) which I can then access from my
FigureRollOver class:
var myRollOvers:Array = new FigureXMLLoader("mod1_fig1.xml");
Here is FigureXMLLoader (see comments in the code for more
details) which obviously does not return an array as it is, because
of all the working around I've had to do. Note the "testing"
variable, which can be traced from the main timeline of the .swf,
but I will get "not what I want" because of course the array hasn't
been built yet, and never will be, inside of the declaration as it
is. How do I get it in there so I can return an array?
Thanks!Suggest you ask this question in the Actionscript forum as
this forum is
more tuned to database integration questions.
You can create arrays outside a class and pass them into it
by reference and
visa versa build arrays inside a class and pass out via
reference.
The preferred approach is to place the array in a class and
not expose it.
Then add methods to use the array or should we say to use the
class.
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"maija_g" <[email protected]> wrote in
message
news:ed4i43$9v0$[email protected]..
> Update: I've now put this on the main timeline of the
.swf:
>
> myRollOversLoaded = false;
> var myRollOvers:Array;
> var roll_content = new FigureXMLLoader("mod1_fig1.xml");
>
> And inside the "myOnLoad" function in FigureXMLLoader,
just after the
> while
> loop I've put this:
>
> _root.myRollOversLoaded = true;
> _root.myRollOvers = figure_arr;
>
> The movie clip rollover won't act until
myRollOversLoaded is true. It
> works,
> but it still seems klugey. Any suggestions for a more
elegant solution
> would be
> appreciated.
>
Maybe you are looking for
-
I have a production DVD which my desktop Mac recognized just fine the other day. Today, it spins for about a minute before being spit back out unrecognized. It IS recognized in my PowerBook and standalone DVD players, and all other DVDs and CDs are r
-
Setting 1920x1080 resolution in second monitor (mirror)
Hola! I have a MacBook Pro 13'' (2011). I'm trying configure a second monitor with the Mac, the second monitor it's a Asus VH226 and Mac recognized it perfectly. I configure the screen mode in mirror screens but the resolution of the second monitor i
-
Mac Book Air, cannot exit Voice Over at initial start up
New Mac Book Air; initial power-up; selected English language; 'Welcome' screen defaults to 'United States'; cannot manually 'Continue' to register and set up; 'esc' results in starting the Voice Over tutorial; 'Command+F5' results in seeing/hearing
-
Settings in RSA1 only show "RSADMINA Maintenance View"
Helly everyone, i want to access the Settings in RSA1 to enable the display of generated objects. But when i click on "Settings" in the toolbar, the only entry availavle is "Global Settings..." which leads to "RSADMINA Maintenance View". Does anyone
-
Can java have Protected or Private Constructor
Hi, can java have Priavte or protected constructor, as we know java have default and public constructor , and in using singleton design patters we can use private & protected constructor, so, what is the main logic, Regards, Prabhat