Topic: XML file system (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=11023" title="Pages that link to Topic: XML file system (Page 1 of 1)" rel="nofollow" >Topic: XML file system <span class="small">(Page 1 of 1)</span>\

 
Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 08-15-2003 04:32

I'm trying to figure out how to use XML to cary site map information over to flash. The real problem is that i don't understand DTD very well and I don't want to try using the same kind of tag over and over or else I won't be able to find the useful stuff.

For example.. um.. beer. So if I was making a tree of information about beer this is what it might look like:
- beer
- - breweries
- - hops
- - - green
- - - brown
- - nutrition information

and then for each item itself there are the folowing potential attributes:
+ the link to the respective web page for more information
+ a thumbnail picture to put beside the link
+ a description of the content to be found

here's what I tried which I do NOT think would support more than two levels. I'm curious if I would be able to construct a DTD that supports any number of parent/child relationships, if there is some other code that could make this work just better or just anything useful.

<!DOCTYPE flashStructure [
<!ELEMENT main (level_1*)>
<!ELEMENT level_1 (image, link, description, level_2)>
<!ELEMENT image (#PCDATA)>
<!ELEMENT link (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT level_1 (level_2*)>
<!ELEMENT level_2 (image, link, description, level_3)>
<!ELEMENT Decsription (#PCDATA)>
<!ELEMENT image (#PCDATA)>
<!ELEMENT link (#PCDATA)>
<!ELEMENT description (#PCDATA)>
]>

Thanks in advance.

Shine and shine. :: [Cell=992] :: [See my team's 30 second animation!! ]

Steve
Maniac (V) Inmate

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

posted posted 08-15-2003 13:51

I guess I don't know enough about beer to see where you're going with your content here. I do know that Flash ishapy with a pretty simple xml structure. In fact, Flash has a non-validating xml parser, so it's up to you to make sure you are passing valid xml, and the presence or absence of a DTD doesn't make any difference to Flash.

The structure you present sort of baffles me:

- beer
- - breweries
- - hops
- - - green
- - - brown
- - nutrition information

I don't know how you intend to use the information, but it might be useful to structure it beer-by-beer:

code:
beers
- beer: name, photo
- brewery
- photo/
- location/
- ingredients
- hops/
- yeast/
- /ingredients
- nutrition
- carbohydrate
- /nutrition
- /beer
/beers


Like I said, it sort of depends on how you want to present and extract information, but the structure of the xml can be pretty simple if the target is Flash, so don't over-complicate it!


[This message has been edited by Steve (edited 08-15-2003).]

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 08-16-2003 06:07

1. I realize that I don't NEED a dtd, but I thought it was a smart move.
2. I'm not using beer, i just made that up as an example. this is for a site map or a front page menu that links to many sub-levels.

I'm still just confused how to be using XML correctly. I'd really like help on the logic that is usually paired with its use. Any links for insight?

Shine and shine. :: [Cell=992] :: [See my team's 30 second animation!! ]

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 08-19-2003 03:37

I'm VERY CLOSE but there's still some work to be done. Here's what's working so far: http://home.osysi.net/xml/parser.php

You'll notice this is basicly how the code is formatted/parsed right now

code:
<flashStructure xmlns:flashStructure="flashStructure.dtd">
<level_1> ... </level_1>
<level_1> ... </level_1>
<level_2> ... </level_2>
<level_2> ... </level_2>
</flashStructure>



When it should look like this instead

code:
<flashStructure xmlns:flashStructure="flashStructure.dtd">
<level_1>
...
</level_1>
<level_1>
...
<level_2>
...
</level_2>
<level_2>
...
</level_2>
</level_1>
</flashStructure>



I'm racking my brain trying to figure out how to run just a function to show one level of data and have an if statement check if the level increases or decreases.. I think I'll figure it out on my own. just wish me luck

Shine and shine. :: [Cell=992] :: [See my team's 30 second animation!! ]

[This message has been edited by Bmud (edited 08-19-2003).]

Steve
Maniac (V) Inmate

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

posted posted 08-19-2003 04:41

"how to run just a function to show one level of data"

a Flash ActionScript function, or a php function?

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 08-22-2003 19:32

That's a good question. I played with the idea of keeping the XML very non-standard and then worrying about the formatting in flash later. Just to make things clear though, I'm trying to figure out how to run just a php function to show one level of data. Then have an if statement check if the level increases or decreases. Then have the primary loops that run both functions as needed.

My first day of college was this past Tuesday, and then my server went down again.. I'm very eager to get back on this project. I'm excited. =)

By the way, thanks everyone for helping me out -- as always.

Shine and shine. :: [Cell=992] :: [See my team's 30 second animation]

Emperor
Maniac (V) Mad Scientist with Finglongers

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

posted posted 08-22-2003 19:41

Bmud: So if I understand correctly you are using PHP to dump the XML for Flash to suck up?

I have done similar things with Steve and I think there are a couple of issues to address:

1. Check to see if you can't keep the XML structure as flat as possible - this makes your life far easier at both ends and should make things go faster.

2. If you need to build complex nested trees then you need to look into recursive functions. If this is the kind of thing you need to do then contact me and I can pass on some of the code I've done. I will work on a tutorial on ths kind of thing eventually but the code should help for now

I can't see your page though that you link to.

___________________
Emps

FAQs: Emperor

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 08-27-2003 15:14
quote:
1. Check to see if you can't keep the XML structure as flat as possible - this makes your life far easier at both ends and should make things go faster.


I was not sure what you meant by that. I've e-mailed you and am awaiting code for reference. Thanks for your help Emps.

[edit]using php.net as a reference is becoming ever more confusing. I'm not a big php programmer.. but this is my idea!

I've got the mysql request for the table (which is resorted not by ID).
So does that mean that $myrow, which I've set to equal the database stuffs, can be called as an array?
calling $myrow[name] brings up the "name" element from one entry. The while loop only works on one entry at a time. Similarly, using $myrow[1] would call up the second element, or "name" again from the same entry. In order to check to see if my next entry goes up or down I need to be able to check the next entry in the table.

I've done this sort of loop-around stuff in flash before and it just involved one of two things
1. moving the checkpoint up to the begining, or otherwise "shifting" the code so that at the end of the function i set a variable to $new and at the begining do a old = new; new = thisEntry; and go from there.
2. I make my if statement using an array like so if(thearray[i].length == thearray[i +1].length)

#2 has been on my mind for a few days now. But it brings back that original problem. Can I access that variable as an array to check the next entry, or if that doesn't work can i just make a while loop at the begining that dumps all of the information in to a tangible array like so

code:
while($myrow = mysql..... SORT by level ASC){
$myrow = $new array[i];
$i++;
}


[/edit]

Shine and shine. :: [Cell=992] :: [See my team's 30 second animation]

[This message has been edited by Bmud (edited 08-27-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

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

posted posted 08-27-2003 16:10

Bmud: I emailed you back last night - if you didn't get it then let me know and I'll resend.

What I mean by keep it as flat as possible is aim for something like:

code:
<node>
<node />
<node />
<node />
</node>



rather than:

code:
<node>
<node>
<node>
<node>
<node />
</node>
</node>
</node>
</node>



You oresented examples with different 'depths' and try to go for one as shallow as possible - there are, of course, circumstances when you need a deeply nested structure and I have sent you an example of how to do that and maintain an track of the depth you are at.

[edit: On the other bits I think you'll have to be clearer and explain what you mean]

___________________
Emps

FAQs: Emperor

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 08-29-2003 00:56

Yes, I remember reading on ultrashock.com that it is good to keep the code very "flat" as you put it. In fact, they suggested removing all cairages and having just one ugly line of code. That was malicious for a while.. Yes I got your email

Shine and shine. :: [Cell=992] :: [See my team's 30 second animation]

Steve
Maniac (V) Inmate

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

posted posted 08-29-2003 16:18

Don't confuse a "flat" structure with stripping white space. The former is a design issue and is worthy of some considerable planning to make things as painless as possible later. The latter simply tries to make the file size smaller by eliminating "unnecessary" characters. Unnecessary for computers that is. One of the charms of xml is its "human readable" nature. You can skim an xml file - it makes sense. Stripping the white space may make a small performance improvement, but at the expense of readibility. If you're having a script write the xml, maybe readability isn't an issue. If you chose to retain the white space for human readability, Flash can easily strip the whitespace by setting the ignoreWhite property to true (this is important - otherwise white space is considered a node and you'll get ALL screwed up when you try to parse the data!).

Whatever. Just don't confuse structure with whitespace.

Steve
Maniac (V) Inmate

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

posted posted 09-04-2003 18:05

Bmud:

Here is one of the more lucid Flash/xml intro tutorials I've run across, by a somewhat notorious Edmonton Flasher who goes by the name "Philter" http://www.studiowhiz.com/tutorials/24/

Well done. Might help, maybe?



[This message has been edited by Steve (edited 09-04-2003).]



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu