Topic: Action Script with XML (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=11009" title="Pages that link to Topic: Action Script with XML (Page 1 of 1)" rel="nofollow" >Topic: Action Script with XML <span class="small">(Page 1 of 1)</span>\

 
bajajvivek
Obsessive-Compulsive (I) Inmate

From: New Delhi
Insane since: Jul 2003

IP logged posted posted 07-14-2003 16:42 Edit Quote

Hi

I have used XMLnitro.as to read XML files in Flash using action script. The code is working fine, but the problem is that the XML files i have to use are very heavy having some 10000 records. The loop gets struck in Parent.Child.Child. The system becomes low on resources. Can any body help me optimise the code so I may be able to handle such big XML Files.

Warm regards
Vivek Bajaj

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

IP logged posted posted 07-14-2003 17:50 Edit Quote

bajajvivek: Welcome. I suspect your problem is the 10k records - that is a lot of processing. I suspect Steve would be better placed to help you on this but I think it is just the amount.

Perhaps if you explain what you are doing and what server-side scripting language you have available then we could look into better solutions.

___________________
Emps

FAQs: Emperor

bajajvivek
Obsessive-Compulsive (I) Inmate

From: New Delhi
Insane since: Jul 2003

IP logged posted posted 07-15-2003 09:59 Edit Quote

Hi

Actually I am working on a XML file of Product Master which has around 10000 records. Now In flash I want to seach for records which start with a particular string which I have entered.

I hope this defines my problem. The actual database contains around 60000 records. I have broken the original file in to different files of characters. like i have a diff file for parts starting with "a" and diff file for parts starting with "b". this has made the database quite small but some files are still very long containing 10000,6000 kind of records. I'll also have to check that the data base is increasing day by day and it can rise to some 2 lac records.

please post any suggestion if you have.


Warm regards
Vivek Bajaj

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

IP logged posted posted 07-15-2003 14:09 Edit Quote

bajajvivek:

quote:
Actually I am working on a XML file of Product Master which has around 10000 records. Now In flash I want to seach for records which start with a particular string which I have entered.



I did look in Google and I still have no idea what Product Master is (link?) but that doesn't seem to be the most efficient way of doing things. I'm not sure how efficient Flash is at searching but it must you must be able to get significant savings in processing if you took the list and whittled it down using a server-side scripting language and then passed the file into Flash to display.

As I don't have any information on what it is, what server-side scripting languages you have available, if the file is being generated by you or being drawn in from outside, etc. I can't give you muh more advice than I'm sure there is a better way.

___________________
Emps

FAQs: Emperor

JKMabry
Maniac (V) Inmate

From: out of a sleepy funk
Insane since: Aug 2000

IP logged posted posted 07-15-2003 16:13 Edit Quote

product master is a "master list" of products that a company sells, containing part numbers, descriptions, upc codes, cost, selling prices etc etc

Jason

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

IP logged posted posted 07-15-2003 18:07 Edit Quote

JKMabry: Thanks for clearing that up - it sounded awfully like a product but that was the conclusion I was coming to after searching.

That is just even more confusing - why not just do the search and pass in the results you want to Flash?

___________________
Emps

FAQs: Emperor

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

IP logged posted posted 07-15-2003 18:26 Edit Quote

I don't know anything about the Flash end of things, but this type of heavy duty processing is obviously not what Flash was made for.

Follow Emperor's advice, and use a server side language to handle the processing and pass only the results to Flash...

bajajvivek
Obsessive-Compulsive (I) Inmate

From: New Delhi
Insane since: Jul 2003

IP logged posted posted 07-16-2003 10:39 Edit Quote

Hi Friends,

Thanks for so many replies. Actually I have to run this application on a pocket PC. Just Imagine there is an XML File containing First Names and Last Names of 60000 people. My original XML File loocked like :-
<names>
<detail first="vivek" last = "bajaj" />
<detail first="gaurav" last = "verma" />
.....
and so on 60000 records
</names>

now what I did was to break this original file into 26 files.
first names starting with "a" in one file
first names starting with "b" in other and so on upto "z"

now this has reduced the size of database very much but still some files contain as much as 10000 records. the size of database is still growing.

last night what i did was make an index tag in my each XML File.
like :-

<names>
<index>
<aa>100</aa>
<ab>200</ab>
<ac>300</ac>
... and so on upto az.
</index>
<detail first="vivek" last = "bajaj" />
<detail first="gaurav" last = "verma" />
<detail first="ashish" last = "gupta" />
</names>

the value in aa and ab tags is their ending record count.

now when I have to look for name "ashish" what I will do is i'll look for <as> tag in index tag and find its value. then I'll find the value of the tag which is previous to <as> that will be <ar>. Now I have the value from which I have to start the loop and at which i have to end the loop. I will not have to read the whole file. of 10000 records. Now where I am struck up is that in a couple of categories there are some 4000 records.
for eg. the names starting with "ap" are 4000. Now when I have to run the loop for 4000 times, even the desktop pc shows low resources.

hope this explains you the whole thing which I want to do.
If any body got any solution or idea either post it or mail me at bajajvivek@hotmail.com.

Thanks in advance

Warm regards
Vivek Bajaj

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 07-16-2003 13:19 Edit Quote

You haven't yet described what you're doing with Flash, other than to say "xmlnitro" and "looping".

First off, xmlnitro was really the only sane way to handle xml parsing in Flash 5, but Flash MX blows the doors off Flash 5 with regard to xml parsing. So if you're plodding thru large databases with Flash 5 and xmlnitro - upgrade to MX! And if you are using MX, eliminate the xmlnitro - the native functions are now faster.

With regard to "looping" - no matter how you try to index your database into "chunks', you still need to load and parse the whole file into Flash before you can begin to loop through it. That's most likely where the slowdown is occurring. Once you have it loaded in an xml object in Flash, what do you do? Are you filling an array, or several arrays with the nodes of the xml? And then looping thru one array seeking a match with an incrementing counter? I would guess that that part wouldn't be hugely time consuming, and I would also guess that, once parsed, 10000 records should be within Flash's capacity to handle.

Guess the bottom line is, more info on the Flash details would help. If we can't come up with a solution, you might also pop into the xml forum at were-here.com - there are some heavy hitters there.

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

minutes later ...
uh - I just actually reread your initial post. Heh. Sorry. So you ARE getting the file to load into Flash okay, it's just bogging down as you try to extract the node data. Okay, well there aren't any generic "fixes" I know (other than to bag xmlnitro for starters), but I can't offer optimization help without seeing what you're doing. Knowing the exact structure of the xml, and your parsing code would help.


[This message has been edited by Steve (edited 07-16-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

IP logged posted posted 07-16-2003 15:22 Edit Quote

bajajvivek: So if I understand properly you have your whole product list in 26 static XML files loaded into a pocketPC and you are using Flash to actually search through them? I presume this is for some kind of stock checking?

If so there are a few solutions:

1. As Steve suggests start using Flash6 (I resume you can upgrade the plugin easily on a pocketPC). However, even if the faster XML processing solves the problem now I'd imagine you'd hit the same wall again.

2. I wonder if it would be possible to load Apache on to a pocketPC - it would depend on the space available but it might actually be possible to run a server on it. I'm not overly confident of this one but if you could you could store it all in a MySQL database.

3. Move to one of the dedicated stock checking handheld tablets which are designed for this kind of thing.

4. Add a wireless network card and have something like an Apache server running elsewhere and passing te info through to your PocketPC.

It all depends on what you are doing and what is available but I suspect moving away from the Flash/XML solution will pay dividends in the long run (for the small amount of effort you'll make things much simpler).

___________________
Emps

FAQs: Emperor

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 07-16-2003 16:30 Edit Quote

Clarify what we are dealing with here - people's first and last names, or products with item numbers.

If the former, the search loop is somewhat complicated by the fact that there could be several people with the same last name - the search doesn't want to terminate with the first match. If the latter, then presumably each sku or product ID is unique and thus the search CAN terminate at the first match.

Using attributes as you indicated in your example is a more Flash-friendly way to structure xml. That's a plus.

In your example, I think I'd just bag the index stuff and go straight for the detail. Just eliminate the index node entirely. In the example following, it's assumed there is no index node.

I'd start by creating 2 arrays: lastArray, firstArray.

code sort of like this (untested, but for an example)

code:
lastArray = new Array();
firstArray = new Array();
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success) {
if (success) {
rootNode = this.firstChild;//use of "this" keyword refers to the myXML object
numEntries = rootNode.childNodes.length;

for (var i=0; i<numEntries, i++) {
lastArray.push(rootNode.childNodes[i].attributes.last;
firstArray.push(rootNode.childNodes[i].attributes.first;
}
}else{trace("failed to load");
}



hah. Top of my head, probably won't work as written, but that's the general idea. Load up two arrays with the data.

Then the movie would have an input text field into which you would enter the last name, maybe called search_txt, and a "search" button. The button would have an onRelease function:

code:
onRelease = function() {
findItem(search_txt.text);//pass input content as argument to findItem function
}

which would trigger a loop which would do something along the lines of:

code:
function findItem (searchString) {
var numRecords = lastArray.length;
for (var i = 0; i<numRecords; i++) {
if(lastArray[i] == searchString) {
return i;
}

}
}



So now "i" is returned as the index of the matching item in the array and you could pull the matching "i" item from firstArray and display the combined results somewhere.

Again - all this is top of head stuff, and most likely won't work as written but it's how I would approach this task. You would also want some mechanism to clear the contents of the search field, some mechanism to report a failure to find a match and, as stated earlier, some recursive mechanism to continue checking for additional matches if your items aren't guaranteed to be unique.

Help some?

johnvarenda
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Jan 2010

IP logged posted posted 01-08-2010 04:19 Edit Quote

I too experience problem in xml files but all of your posting helps me a lot to overcome..
Thanks for the posting.
......................
data entry india

DanXS
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Mar 2010

IP logged posted posted 03-03-2010 06:42 Edit Quote

Bit long winded, but I would use the XML to populate a database then make queries on the database for subsets of data and have it return the data in XML. Or if you try and get the data directly into your actionscript with AMF format which is more compact binary format that should be faster. I have been using AMFPHP and mysql with PHP at back end. But it is a bit more work, plus you would need a way to get the XML and pupulate the database with it. Create the tables etc. If your not a PHP person, I think there are lots of other languages you can write services in to read stuff from a database. If you want to work with just XML file, XPath http://www.w3.org/TR/xpath/ helps with extracting parts of your XML file I think. Not sure about how to use it in actionscript though, but i just did google search and found this http://www.robgonda.com/blog/index.cfm/2006/2/19/Xpath-for-ActionScript--now-documented. Finally you could also convert XML to JSON, which is a bit more compact, but probably still slow because still text format, so the parsing could be slow and all the numbers have to be converted from text to binary which obviously takes time.

Good luck



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu