This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-12-02 12:33:46

throughthefire
Scratcher
Registered: 2009-07-09
Posts: 1000+

Xml...

I'm learning it! More specifically XSLT, though.

Does anyone else here know XML? It's probably the easiest to learn markup language out there! But it's really useful  big_smile .

Here's an example of some code I typed up this morning (with the XSLT code):

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="testing.xsl"?>

<Collection>
        
        <Game>
            <Title>Legend of Zelda</Title>
            <Genre>Adventure</Genre>
            <Year>1986</Year>
            <Rating>E10</Rating>
        </Game>
        
        <Game>
            <Title>Super Mario Bros.</Title>
            <Genre>Platforming</Genre>
            <Year>1985</Year>
            <Rating>E</Rating>
        </Game>
        
        <Game>
            <Title>Minecraft</Title>
            <Genre>Indie</Genre>
            <Year>2011</Year>
            <Rating>NA</Rating>
        </Game>
    
</Collection>

Code:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <html>
        <body>
            <h1>My game collection</h1>
            <table border="2">
                <tr>
                    <th>Title</th>
                    <th>Genre</th>
                    <th>Release Date</th>
                    <th>ESRB Rating</th>
                </tr>
                
                <xsl:for-each select="Collection/Game">
                
                <tr>
                    <td><xsl:value-of select="Title" /></td>
                    <td><xsl:value-of select="Genre" /></td>
                    <td><xsl:value-of select="Year" /></td>
                    <td><xsl:value-of select="Rating" /></td>
                </tr>
                
                </xsl:for-each>
            </table>
        </body>
    </html>
</xsl:template>

</xsl:stylesheet>

SImplistic, I know, but I'm still learning!


Back. For now. Maybe.

Offline

 

#2 2011-12-02 12:36:32

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Xml...

I don't get why I'd use it.


Posts: 20000 - Show all posts

Offline

 

#3 2011-12-02 12:38:17

throughthefire
Scratcher
Registered: 2009-07-09
Posts: 1000+

Re: Xml...

veggieman001 wrote:

I don't get why I'd use it.

XML is great for creating databases, and XSL is used to display them.


Back. For now. Maybe.

Offline

 

#4 2011-12-02 12:41:18

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Xml...

I love XML but i really really really love JSON more ^^ lol maybe just me


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#5 2011-12-02 12:41:22

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Xml...

throughthefire wrote:

veggieman001 wrote:

I don't get why I'd use it.

XML is great for creating databases, and XSL is used to display them.

Oh. Why not just use PHP and MySQL?


Posts: 20000 - Show all posts

Offline

 

#6 2011-12-02 12:44:53

throughthefire
Scratcher
Registered: 2009-07-09
Posts: 1000+

Re: Xml...

veggieman001 wrote:

throughthefire wrote:

veggieman001 wrote:

I don't get why I'd use it.

XML is great for creating databases, and XSL is used to display them.

Oh. Why not just use PHP and MySQL?

Meh. XML is simpler.


Back. For now. Maybe.

Offline

 

#7 2011-12-02 12:47:06

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Xml...

throughthefire wrote:

veggieman001 wrote:

throughthefire wrote:


XML is great for creating databases, and XSL is used to display them.

Oh. Why not just use PHP and MySQL?

Meh. XML is simpler.

But how do you use in in a web page? Can you actively update it?


Posts: 20000 - Show all posts

Offline

 

#8 2011-12-02 12:49:39

throughthefire
Scratcher
Registered: 2009-07-09
Posts: 1000+

Re: Xml...

veggieman001 wrote:

throughthefire wrote:

veggieman001 wrote:


Oh. Why not just use PHP and MySQL?

Meh. XML is simpler.

But how do you use in in a web page? Can you actively update it?

You create the database, then write a style sheet to tell the browser how to display it.


Back. For now. Maybe.

Offline

 

#9 2011-12-02 12:52:53

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Xml...

throughthefire wrote:

veggieman001 wrote:

throughthefire wrote:


Meh. XML is simpler.

But how do you use in in a web page? Can you actively update it?

You create the database, then write a style sheet to tell the browser how to display it.

But can you actively change the database from page input?


Posts: 20000 - Show all posts

Offline

 

#10 2011-12-02 12:53:59

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Xml...

veggieman001 wrote:

I don't get why I'd use it.

XML is used for storing information in a computer & reader friendly form its close to both

consider a .dat file in C++ generally it will look like thrash , same with a pdf [if u dont trust me open a pdf inside notepad and try reading) . On the other hand XML offers data to be stored like

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="testing.xsl"?>

<Collection>
        
        <Game>
            <Title>Legend of Zelda</Title>
            <Genre>Adventure</Genre>
            <Year>1986</Year>
            <Rating>E10</Rating>
        </Game>
        
        <Game>
            <Title>Super Mario Bros.</Title>
            <Genre>Platforming</Genre>
            <Year>1985</Year>
            <Rating>E</Rating>
        </Game>
        
        <Game>
            <Title>Minecraft</Title>
            <Genre>Indie</Genre>
            <Year>2011</Year>
            <Rating>NA</Rating>
        </Game>
    
</Collection>

Now very simply you can understand this part of code
The above example shows a <Collection>,
this  collection contains many <game>s
each game has some properties say <title>,<Genre>,<Year>,<Rating>.

you can see the difference youself how much xml helps you in keeping the saved file user friendly , it allows you to work on cross language applications say ur server generates an xml file which your client reads . [ this xml file saves you a lot of client side processing as xml parser are native in all browsers ]. Or say you want to make some common file which many programs on your computer will read so there two ways

1 -> Write a class and load the data in class everytime and this class will be very hard to change [as a small change in a single program will make u bind to re-write all programs that read the file].
2 -> Write an  XML file and use an xmlparser now no program will messup if you change the data structure as if it dosnt understands what a tag means it will just ignore it  wink  .
---

XML is also helpful when your program has continous feature addition [and this program takes feed from server], now version 0.1 wont understand version 0.6's uber new features but it should atleast display some information . here xml plays a very important role , likewise the last example the <tag> it dosnt understand will be ignored by the version of client and hence it wont mess things up.

Now makes sense why to use xml [ or JSON or something similar]


makes sense now ?


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

Board footer