Creating a function and return something from an XML file
Hi!
I'm working with timeline actionscript. I want to create a function that loads my xmlfile and returns an xmlobject with the file's content.
This is what I got so far:
my_btn.addEventListener(MouseEvent.CLICK, getXML("myxml.xml")); //1067: Implicit coercion of a value of type void to an unrelated type Function.
function getXML(fn:String):void{
var infoLoader:URLLoader = new URLLoader();
infoLoader.addEventListener(Event.COMPLETE, xmlLoaded);
infoLoader.load(new URLRequest(fn));
var myXML:XML = xmlLoaded(); //1136: Incorrect number of arguments. Expected 1.
trace(myXML);
function xmlLoaded(e:Event):XML{
return e.target.data;
//trace(e.target.data);
Can anyone take a look and perhaps point me in the right direction?
Thanks
I have never used a listcomponent, so I can only help with the steps before filling it with data.
I think you should at start of your application load the XML with filenames and just after it's completed, e.g. in Event.COMPLETE handler, load all other XMLs looping through filenamesXML, like this
var filenamesXML:XML;
var XMLsToLoad:uint = 0;
function filenamesXMLLoaded(e:Event):void
filenamesXML = XML(e.target.data);
XMLsToLoad = filenamesXML.filenames.children().length();
for (var i:uint =1; i < filenamesXML.filenames.children().length(); i++)
getXML( filenamesXML.filenames.children()[i] ); // the function from my previous post, don't forget to implement it
//modify the minor xml load handler from the previous post
function xmlLoaded(e:Event):void
var loadedXML:XML = XML(e.target.data);
xmlArray.push(loadedXML);
XMLsToLoad--;
//assign the one click handler to all buttons, a loop here would be quite handy
function clickHandler(e:MouseEvent):void
if (XMLsToLoad == 0) //check if all xmls have been completely loaded
switch (e.target.name) // swith by clicked button's instance name
case "button_1":
// here you have to implement supplying listcomponent with data, I think a loop again will be a good idea
break;
case "button_2":
// ibid.
break;
Regards,
gc
Similar Messages
-
How to store ,retreive and edit data from an xml file
I am new to XML. I am creating a phone book in JSP with backend as an XML file.How can I store retrieve and edit datas from a jsp file.
Please provide me with examples.I dont want to use bean.
Please provide examplesYou will have to do some leg-work yourself. You will probably want to use DOM to parse and manipulate your XML data. Xerces (xml.apache.org) is a good open source parser. There are extensive examples on their site.
- Saish -
Loading an xml file from an xml file
I'm trying to load an xml file from an xml file, but I'm
having problems. My first xml file is really simple - it only
contains one attribute with the name of another xml file in it
(eventually I will have multiple xml files in here and run a loop
on them...this is why I want to load an xml file from an xml file).
Currently, with the code below, I can get the main xml file
to load ("main.xml"), but I cannot get the secondary xml files to
load FROM the main.xml.
I want to then take childNode values from the secondary xml
file and use them within my .swf in text boxes and whatnot.
Any guidance? I think I'm going wrong on the line where I'm
saying "i.newxml.load(i.attributes.location);"
- How can I get this to work?johnypeter:
I tried changing the code inside the loop to use just
"newxml" instead of "i.newxml", and I declared with "var newxml =
new XML();" - was this what you were thinking?
kglad:
The reason I tried to use the loadXML() function in the loop
was so that for each node in my "main.xml" it would load the new
xml file listed - this is a no-no? Do you have any ideas as to what
I could do?
For the for-loop, what should I change in it? I'm not great
with loops so I tried to modify some code from another loop I found
in another forum thread - not the right way to do it here?
Also, what should I trace? The value of the _root.address, or
i.attributes.location? I have created dynamic text boxes on my
stage to see if the correct value from the xml file loads (ie. the
name of the xml file within the xml file) and it does, but now I
don't know how to put that information into ANOTHER loadXML()
function and get the node information from it - does that make
sense???
Below are the examples of the xml files I am using. In the
first one, main.xml, I will have a list of multiple xml files, each
with the same nodes and elements as in the details.xml file
(different values, of course).
This is just to give you an example of what I'm trying to
accomplish - pulling ALL the addresses and phone numbers from
multiple xml files. I cannot manually collect this information, as
it is dynamic, and will be updated in each individual details.xml.
I was hoping to collect the information by simply adding to and
updating ONE xml file - main.xml.
Do you think this can be done? Am I going about it the wrong
way? I'm quite limited in AS knowledge, which is why I'm piecing
together code from other posts! -
How can I create a function of sound volue from time using AudioQueueBufferRef??
I have a question how can I analyze class AudioQueueBufferRef, for creating a function of sound volue from time?? Here is what I get . there is AudioQueueBufferRef fillBuf = audioQueueBuffer[fillBufferIndex]; volume height is 2000 elements from SInt16* coreAudioBuffer = (SInt16*)fillBuf->mAudioData. so function looks like H(t*i)=coreAudioBuffer[i] where t = 1/sampleRate = 1/22050 but here is a problem. my program gets sound and uses a class AudioStreamer for this. AudioStreamer has 3000 lines when I play music from Free Internet Radio - SHOUTcast Radio - Thousands of Free Online Radio Stations. internet radio - my problem is as follows either I dont know where 85 % of sound information is or I dont know how I can analyze class AudioQueueBufferRef
Here is the code where I analyze Buffer.
{@synchronized(self)
if ([self isFinishing] || stream == 0)
return;
inuse[fillBufferIndex] = true; // set in use flag
buffersUsed++;
// enqueue buffer
AudioQueueBufferRef fillBuf = audioQueueBuffer[fillBufferIndex];
fillBuf->mAudioDataByteSize = bytesFilled;
// ======>in this place I analyze Buffer
if (packetsFilled)
err = AudioQueueEnqueueBuffer(audioQueue, fillBuf, packetsFilled, packetDescs);
else
err = AudioQueueEnqueueBuffer(audioQueue, fillBuf, 0, NULL);
when bitRate = 24 buffer has the following options int size=(fillBuf->mAudioDataByteSize) == 2000 double sampleRate=asbd.mSampleRate == 22050 numberOfChannels = asbd.mChannelsPerFrame == 1 it turns out that duration of play buffer float bufferTime =(size/numberOfChannels)/sampleRate == 0.1 number of buffers per second float numBuffersInOneSeconds == 1,5 duration of play all buffers per one second numBuffersInOneSeconds * time == 0.15 so it is 15 % of all information
as a result If buffer comes at 0.0 seconds he lasts up to 0.1 seconds.farther in my function there is no volume. second buffer comes in 0.7 seconds and lasts up to 0.8 seconds. but in reality the sound doesnt breaks. Maybe I'm doing something wrong .please tell me.
just for comparison
when bitRate = 32 buffer has the following options int size=(fillBuf->mAudioDataByteSize) == 2000 double sampleRate=asbd.mSampleRate == 22050 numberOfChannels = asbd.mChannelsPerFrame == 1 it turns out that duration of play buffer float bufferTime =(size/numberOfChannels)/sampleRate == 0.1 number of buffers per second float numBuffersInOneSeconds == 2 duration of play all buffers per one second numBuffersInOneSeconds * time == 0.2 so it is 20 % of all information
when bitRate = 32 buffer has the following options int size=(fillBuf->mAudioDataByteSize) == 1660 double sampleRate=asbd.mSampleRate == 44100 numberOfChannels = asbd.mChannelsPerFrame == 2 it turns out that duration of play buffer float bufferTime =(size/numberOfChannels)/sampleRate == 0.02 number of buffers per second float numBuffersInOneSeconds == 10 duration of play all buffers per one second numBuffersInOneSeconds * time == 0.2 so it is 20 % of all informationYou cannot write custom commands for expressions.
That being said, there are a couple of options:
Create a subsequence with a single step. Use a parameter of the sequence as "function parameter".
Create a custom step type including a substep module which implements the function. Add an edit substep to enable the user of the steptype to gracefully change the parameter.
Store the variable parameter in a local/file global variable and modify the value in each step. This will, at least, keep the "function" the same for every step.
Norbert -
How to create a function that returns multiple rows in table
Dear all,
I want to create a funtion that returns multiple rows from the table (ex: gl_balances). I done following:
-- Create type (successfull)
Create or replace type tp_gl_balance as Object
PERIOD_NAME VARCHAR2(15),
CURRENCY_CODE VARCHAR2(15),
PERIOD_TYPE VARCHAR2(15),
PERIOD_YEAR NUMBER(15),
BEGIN_BALANCE_DR NUMBER,
BEGIN_BALANCE_CR NUMBER
-- successfull
create type tp_tbl_gl_balance as table of tp_gl_balance;
but i create a function for return some rows from gl_balances, i can't compile it
create or replace function f_gl_balance(p_period varchar2) return tp_tbl_gl_balance pipelined
as
begin
return
(select gb.period_name, gb.currency_code, gb.period_type, gb.period_year, gb.begin_balance_dr, gb.begin_balance_cr
from gl_balances gb
where gb.period_name = p_period);
end;
I also try
create or replace function f_gl_balance(p_period varchar2) return tp_tbl_gl_balance pipelined
as
begin
select gb.period_name, gb.currency_code, gb.period_type, gb.period_year, gb.begin_balance_dr, gb.begin_balance_cr
from gl_balances gb
where gb.period_name = p_period;
return;
end;
Please help me solve this function.
thanks and best reguardhi,
Use TABLE FUNCTIONS,
[http://www.oracle-base.com/articles/9i/PipelinedTableFunctions9i.php]
Regards,
Danish -
Trying to fetch a value in a java function and returning the array.
hello....I am trying to fetch a value in a java function and returning a array......I already write the pl/sql function which is working fine....but i think i m lost......when i run it through the jsp it shows me error........pls help
java code:=
public String [] viewx(String bid) throws SQLException, Exception {
String [] values;
try {
CallableStatement cstmt = null;
String SQL = "{?=call vi_dis.v_dis(?)}";
cstmt = con.prepareCall(SQL);
cstmt.registerOutParameter(1,Types.ARRAY);
cstmt.setString(2, bid);
cstmt.execute();
Array simpleArray = cstmt.getArray(1);
values = (String [])simpleArray.getArray();
cstmt.close();
} catch (SQLException sqle) {
error = "SQLException: Could not execute the query.";
throw new SQLException(error);
} catch (Exception e) {
error = "An exception occured while retrieving emp.";
throw new Exception(error);
return values;
pl/sql function
create or replace package vi_dis
as
function v_dis(vbid IN student.bid%type) return stuarray ;
end;
create or replace
package body vi_dis
as
function v_dis(vbid IN student.bid%type) return stuarray
is
l_stu stUarray :=stuarray();
cursor c_sel
is
SELECT CNAME
FROM COURSE C,ENROLL E
WHERE C.CID=E.CID
AND E.BID=vbid;
BEGIN
OPEN c_sel;
FETCH c_sel BULK COLLECT INTO l_stu;
l_stu.extend;
CLOSE c_sel;
RETURN l_stu;
EXCEPTION
WHEN NO_DATA_FOUND
THEN DBMS_OUTPUT.PUT_LINE('NO RESULT AVAILABLE');
CLOSE c_sel;
END;
END;
/BalusC wrote:
It is comparing the selected value against the List<SelectItem> returned by getSetoresOrigem() as it is during the apply request values phase of the form submit request.Ok. That's what I supposed JSF was doing.
BalusC wrote:
If the selected value isn't in there, then you will get this error.I can understand this, but is this right? As I said, the old value isn't really there because I changed the list values to new ones. But the new value (the value of fSetorOrigem ) corresponds to a value that exist in the new list items, so a valid value. So JSF is not considering that I also changed the list, not just the value. It is comparing the new value with the old list, not the new one. Acting like this JSF is making the page looks like a static HTML page, not a dynamic one. If I can't change the list and the value, what's the point of that? In my point of view I'm not doing anything wrong, I'm not violating any JSF rules.
Marcos -
How to create business functions and expose as webservice?
Hi...
How to use Java to create business functions and expose that as a webservice.Hi Leela,
Can you please post the answer to the question posed?
We are also looking for a similar implementation in our integration and would really appreciate any help.
Regards -
I created in iMovie, and extracted audio from one of the clips to use in the title sequence. All is well, export to iDVD and it plays OK, but when I burn the DVD the audio for the titles does not play. Any suggestions?
I am on a MacBook Pro with OS 10.6.7 running iMovie '11 and iDVD 7.1.1. Thanks for any input.
-
If i am making an app, and copy something from a site that may is copyrighted and make money on it will that be illigal ?
Just like 10 best jokes etc.That would be a copyright violation.
If Apple requests it, you have to be able to show documentation that shows you have the right to use the content in your app. -
Create a list from an XML file no display
I have a multiline Dynamic text box called projList.
I am trying to populate it from an xml file and create a
clickable list.
The trace works but cannot get to display the list in the
text box.
As far as the clickable goes, haven't gotten that far yet.
Help very much appreciated.
The xml is structured like this:
<?xml version="1.0" ?>
- <images>
- <pic>
<Image>/Butler/Images/sfah2_small.jpg</Image>
<Category>Institutional</Category>
<Proj_title>FRESH AIR HOME</Proj_title>
Please see code below:
import mx.xpath.XPathAPI;
var allproj_xml:XML = new XML();
allproj_xml.ignoreWhite = true;
allproj_xml.onLoad = function(success:Boolean) {
trace("onload...");
if (success) {
trace("success...");
var thePath_str:String = "/images/pic/Proj_title";
var title_array:Array =
XPathAPI.selectNodeList(this.firstChild,
thePath_str);
for (var i:Number = 0; i < title_array.length; i++) {
trace(title_array
.firstChild.nodeValue);
projList.addItem(title_array.attributes.Proj_title);
} else {
trace("error loading XML");
allproj_xml.load("allimages.xml");
stop();This did it:
projList.addItem(title_array
.firstChild.nodeValue);
> Thanks for your response.
> How can I add what I am tracing, to the component
properly?
>
> "DMennenoh **AdobeCommunityExpert**"
<[email protected]> wrote in
> message news:eqaejh$bi8$[email protected]..
>>>>trace(title_array.firstChild.nodeValue);
>> projList.addItem(title_array
.attributes.Proj_title);
>>
>>
>> Your code seems OK. What you are tracing here
however isn't what you're
>> adding to the component. Are you sure what you're
adding traces?
>>
>> --
>> Dave -
>> Head Developer
>> www.blurredistinction.com
>> Adobe Community Expert
>>
http://www.adobe.com/communities/experts/
>>
> -
XMLTABLE function not returning any values if xml has attribute "xmlns"
Hi,
XMLTABLE function not returning any values if xml has attribute "xmlns". Is there way to get the values if xml has attribute as "xmlns".
create table xmltest (id number(2), xml xmltype);
insert into xmltest values(1,
'<?xml version="1.0"?>
<emps>
<emp empno="1" deptno="10" ename="John" salary="21000"/>
<emp empno="2" deptno="10" ename="Jack" salary="310000"/>
<emp empno="3" deptno="20" ename="Jill" salary="100001"/>
</emps>');
insert into xmltest values(2,
'<?xml version="1.0"?>
<emps xmlns="http://emp.com">
<emp empno="1" deptno="10" ename="John" salary="21000"/>
<emp empno="2" deptno="10" ename="Jack" salary="310000"/>
<emp empno="3" deptno="20" ename="Jill" salary="100001"/>
</emps>');
commit;
SELECT a.*
FROM xmltest,
XMLTABLE (
'for $i in /emps/emp
return $i'
PASSING xml
COLUMNS empno NUMBER (2) PATH '@empno',
deptno NUMBER (3) PATH '@deptno',
ename VARCHAR2 (10) PATH '@ename',
salary NUMBER (10) PATH '@salary') a
WHERE id = 1;
The above query returning results but below query is not returning any results because of xmlns attribute.
SELECT a.*
FROM xmltest,
XMLTABLE (
'for $i in /emps/emp
return $i'
PASSING xml
COLUMNS empno NUMBER (2) PATH '@empno',
deptno NUMBER (3) PATH '@deptno',
ename VARCHAR2 (10) PATH '@ename',
salary NUMBER (10) PATH '@salary') a
WHERE id = 1;
how to get rid out of this problem.
Thanks,
-ManiAdded below one in xmltable, its working now.
XmlNamespaces(DEFAULT 'http://emp.com') -
Getting data from an XML file and pushing it to a database
I need to create a coldfusion page that grabs an incoming xml file, extract the data and then push it into a database. I have never done anything like this, and have been reading as much as I can find. Can anyone recomend a good resource or give me a hand on how I go about doing this?
The xml file is coming from another page. Basically the source page is a simple text box that an xml file is pasted into and submited. The action page must grab the xml file, pull out the data and funnel it into a table. Then it must query the table and based on the results of the query, push a new xml file back to the user.
<my brain is already hurting>I'd start by looking at the CF documentation related to XML and Ben Forta's books.
"About XML and ColdFusion" from CF docs:
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec133ba -8000.html
Ben Forta's books
http://www.forta.com/books/0321679199/
It would be good to know:
1. What the workflow is for your task. Can you describe your task in detail and provide samples of the XML and database?
2. The database you are using and the structure of your tables.
3. The version of CF you are using. -
I want to embed text AND image from same XML file
Hey,
I got following problem:
I want to put 1 image AND my text in 1 external XML file.
I can load either one of them in seperate XML files.
I need this because I want my content to be scrollable on my website and with this my image has to scroll with my text.
I got following AS3 put in now:
(ACTIONSCRIPT3.0)
//LOADING EXTERNAL XML & IMAGE//
var xml:XML;
var urlRequest:URLRequest = new URLRequest("externaltext/welkom_content.xml");
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
urlLoader.load(urlRequest);
function urlLoader_complete(evt:Event):void {
xml = new XML(evt.target.data);
welkom_content_text.text = xml.toXMLString();
//LOADING EXTERNAL PICTURES//
var xmlData:XML=new XML();
var pHeight:Number = 200;
var pWidth:Number = 200;
var listLoader:URLLoader = new URLLoader( new URLRequest("externaltext/testxmlimage.xml") );
var picLoader:Loader = new Loader();
listLoader.addEventListener(Event.COMPLETE, gotList);
function gotList(evt:Event):void {
var xmlData:XML = XML(listLoader.data);
var numImages:Number = xmlData.pix.length();
var stImage:String = xmlData.image
picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, gotPic);
picLoader.load( new URLRequest(stImage) );
listLoader.removeEventListener(Event.COMPLETE, gotList);
function gotPic(evt:Event):void {
var thisBmp:Bitmap = Bitmap(evt.target.content);
thisBmp.x = 0;
thisBmp.y = 0;
var thisWidth:Number = thisBmp.width;
var thisHeight:Number = thisBmp.height;
thisBmp.scaleX = pWidth/thisWidth;
thisBmp.scaleY = pHeight/thisHeight;
addChild(thisBmp);
picLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, gotPic);
(/ACTIONSCRIPT3.0)
And my XML file for the text content is as following:
(XML TEXT FILE)
<?xml version="1.0" encoding="utf-8"?>
.... ALL OF MY CONTENT
(/XML TEXT FILE)
And for my image the XML file is as following:
(XML IMAGE FILE)
<?xml version="1.0" encoding="utf-8"?>
<imagelist>
<image>externaltext/testpicxml.jpg</image>
</imagelist>
(/XML IMAGE FILE)
Does anyone know how to fix this and how to do it?
Thanks in advance!
Every help is appreciated!Thanks!
And again... I'm doing some things wrong.. I feel dumb!
Trying to make a website in ASP.NET almost whole day, so my head isn't set to AS3 at all..
My code now to embed XML looks like:
var xml:XML = new XML();
var XMLURL:String = "externaltext/welkom_content_pic.xml";
var myXMLURL:URLRequest = new URLRequest(XMLURL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
var page:Sprite = new Sprite();
myLoader.addEventListener("complete", urlLoader_complete);
function urlLoader_complete(evt:Event):void {
addChild( page );
page.addChild( welkom_title_text );
page.addChild( welkom_content_text );
page.addChild( welkom_image_holder );
xml = new XML(evt.target.data);
welkom_title_text.text = [email protected]();
welkom_content_text.text = xml.item.toString();
//use URLLoader to load the image from the path [email protected]()
Probably set some things wrong..
And what exactly do I have to set to load my image with it?
We were all a beginner once.. but I'm the uber annoying beginner I think... hehe
I probably won't be answering untill thursday, because I got a day off, so..
Thanks!!!!!!!!!!!!!!!! -
I would like to cut and paste information from a word file onto a pdf file, as well as draw lines onto the pdf file. How can I accomplish that task? Is there software I can purchase?
Hi jgallu7382,
The latter is easily accomplished using the Drawing Markup tools, which are available in both the free Adobe Reader, and in Acrobat. Copying/pasting text into the PDF is something that you could do using the editing tools that are available only in Acrobat. Note, however, that Acrobat isn't intended to be a text-editing application, so editing there won't be as robust as in an application designed specifically for that purpose. (It's also worth mentioning that you won't be able to alter a PDF if it has document permissions applied that would prevent you from doing so.)
I hope that answers your questions.
Best,
Sara -
Hi, extract data from xml file and insert into another exiting xml file
i am searching code to extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
1st xml file which has two lines(text1.xml)
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:PrintDataRequest xmlns:xs="http://com.unisys.com/Anid"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
<xs:Person>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
These two lines has to be inserted in the existing another xml(text 2.xml) file(at line 3 and 4)
Regards,
bubblyJadz_Core wrote:
RandomAccessFile? If you know where you want to insert it.Are you sure about this? If using this, the receiving file would have to have bytes inserted that exactly match the number of bytes replaced. I'm thinking that you'll likely have to stream through the second XML with a SAX parser and copy information (or insert new information) as you stream with an XML writer of some sort.
Maybe you are looking for
-
PL/SQL API for Creating Sales Order
Hi, I am new to Oracle SOA 11g. I have done the Deleting Sales Order using PL/SQL API ( Oracle Apps Adapter ) [ API Name: OE_ORDER_PUB.DELETE_ORDER ] in SOA BPEL. While executing the BPEL, it is correctly deleting Sales Order in E Business Suite whic
-
Native iOS L2TP VPN not working on Lion Server
Hi Folks, I have a very strange issue concerning making VPN work on two iOS devices I have. I have recently setup Lion Server on a MacMini here in the office with L2TP VPN using a shared secrert phrase and a password authentication. I have Lion runni
-
OAAM purge/archive impact on "safe" device registration
Does running the OAAM purge/archive process remove registration of "safe" devices and cause users to have to re-register safe devices? For example if the scripts are configured to purge data older than 30 days would users lose their device registrati
-
Export Pics AND retain directory structure
I'd like to use Bridge to manage the photos I put onto my iPod, here's the general workflow: All pictures are stored in directories by event (date) in the /pictures/ folder, for example: /pictures/2008-07-01 Hike in Woods /pictures/2008-07-02 Bike in
-
Hi, everyone. I wrote a program to use httpConnection, and it runs well in the simulator, but when it is running in a mobilephone (Nokia Ngage), a NullPointerException is thrown. Why? The phone can link to Internet through WAP, and some other Java br