SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Beginner at XML

  1. #1
    Web Design Addict
    Join Date
    Mar 2004
    Posts
    2,152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Beginner at XML

    Okay...I've check out www.w3schools.com and have a basic understanding of how XML is written. What I don't understand is what for? w3schools kept saying XML itself doesn't DO anything. Well if it doesn't do anything, why write it? I see all these RSS feeds and stuff but don't understand. Its just not clicking with me. I think I could write an XML document fairly easily, but after that I wouldn't know what to do with it.

    Any help appreciated.

    -Deron

  2. #2
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XML is a data language, it is meant to store information.
    It is useful because its a flat file that can be parsed by many different types of programs.

    RSS is one XML scheme that is used to let information be accessed by many different news reader applications. it establishes a common language for such programs to understand.

    XML lets anyone create a custom markup for any purpose they might need. For example, I made a flash charting application. It need to be able to run on any web server and not require a DB. So I used XML to store the data. I can create my own tags like <bar> or <pie> or whatever! thats the beauty of it!

    With HTML you have a bunch of tags, but they dont give you any clue of what information is actually contained between them. With XML, if I had the tags <chart> and <bar>, youd probably be able to figure out what kind of data it was....

    XML is used with web services because no matter what language you are usng (PHP, ASP, JSP, Perl, Actionscript, etc etc etc), you can understand XML.

    XML tutorials tend to be really stupid... they are usually a list of people or items on a restaurant menu... blah blah blah

    the best way to learn it to use it for something. but looking at a possibly very complex RSS feed isnt a good way to start... might scare you away!

    If you know flash, try using XML with flash. If you are good at PHP, try it with PHP. In both cases there are great tutorials over at kirupa.com

    you could make an XML photo gallery, (store photo filenames and captions in XML)
    of an XML based MP3 players, where the song info was stored in an XML file.
    James Rice :: Ex-Mentor
    www.jamesrice.net

  3. #3
    Web Design Addict
    Join Date
    Mar 2004
    Posts
    2,152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So with the RSS...when I click on the RSS symbol on everyones pages, it just takes me to the XML document. Is that what's it suppose to do or do I need some sort of RSS software to read the XML feed?

    Like you were also talking about using it with flash or PHP...I'm not really familar with either...a little, but not much. So you're saying you can use PHP to view an XML document or display it? I'm gonna check out the website you gave me too.

    Thanks

  4. #4
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a program that reads RSS feeds
    http://www.wildgrape.net/
    James Rice :: Ex-Mentor
    www.jamesrice.net

  5. #5
    Grr. Arrgh. Mr. B's Avatar
    Join Date
    Dec 2004
    Location
    The Hut
    Posts
    817
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the info, JR. This actually makes more sense of XML and what it does. So you're saying you can actually name your tags whatever you want in order to show what information is contained within?

  6. #6
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly

    so you can make up XML Schemes for anything

    list of employees
    restaurant menu
    financial data
    movies
    etc etc etc

    and in each case someone looking at the raw XML would be able to tell whats going on.

    there are more advanced things you can do with something calle XSLT, this is used to transform XML into something else. I say we leave that one for another day
    http://www.w3.org/TR/xslt
    James Rice :: Ex-Mentor
    www.jamesrice.net

  7. #7
    Web Design Addict
    Join Date
    Mar 2004
    Posts
    2,152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay...so hypothetical here. I work for a company that wants an XML scheme of employees. I can write the XML and anyone that wants to view the XML feed of the employees they just need the software which you gave me above or any other program that is like it?

  8. #8
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well that software only applies to RSS specifically......

    RSS is its own XML Scheme that follows certains rules....


    Could you make a custom list of employees, Sure. Would it be readable by an RSS reader, No.
    James Rice :: Ex-Mentor
    www.jamesrice.net

  9. #9
    Web Design Addict
    Join Date
    Mar 2004
    Posts
    2,152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay...I guess I just need to read more or something. I just am lost here. After the XML document is complete I have no idea what to do with it. Or how I can write and XML document of employees, how its used after that. lol

  10. #10
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use XSLT (w3schools has a beginners tutorial I think) to translate the XML to HTML. Or you could write a PHP frontend to the XML document. The possibilities are endless. It's just like any database, you can do so much with it. I would advise you read a bunch of basic XML tutorials if you're not quite sure what's being talked about here.

  11. #11
    SitePoint Addict KelliShaver's Avatar
    Join Date
    Mar 2003
    Location
    Morehead, KY
    Posts
    308
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XML is a means of structuring your data (using whatever schema you choose to use).

    Take an RSS feed, for instance. It outputs XML formated data following a certain set of rules (the RSS schema). What that does is then allow anyone to access that data and interpret it on any operating system, with any language they choose.

    It works wonderfuly as a data transport language.

    Two companies with completely different systems and completely different intranets, written in different languaegs and different databases can share information back and forth, using an agreed upon XML schema and so on.

  12. #12
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by deronsizemore
    Okay...I guess I just need to read more or something. I just am lost here. After the XML document is complete I have no idea what to do with it. Or how I can write and XML document of employees, how its used after that. lol
    XML is merely a way to store structured data. Like others have said, RSS is just one set of XML tags that has been adopted and used a lot. If you wanted to create your own tag scheme for an employee listing, you would list out all the tags you want somewhere, and define how any software written for that data would access it. Think of XML as a "database" of sorts (and I am using that term very loosely): the tags you define are your schema, like the tables and columns in a database. The data you store within those tags would act like database records. And any software you write to work with that data is like your database system (for example, like the frontend in Access).

    The beauty of XML is that nearly every programming language in use today can work with it. For example, there are XML parsers available for Java, C#, VBScript, Javascript, Python, and many more languages. They all tend to use the standard DOM (It's the same way you use Javascript in HTML pages), so working in different languages is easy because the methods/properties tend to stay the same. That means that anybody can use your XML data and you don't have to write as much documentation. You can just say "Here are the tags to look for, use your favorite language and its XML parser" .

  13. #13
    SitePoint Evangelist comfixit's Avatar
    Join Date
    Dec 2004
    Location
    Pasadena
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was confused as well and it took me a long time to figure alot of this stuff out.

    To simplify things.

    First just think of XML as very similar to HTML in structure but you have to always have closing tags.

    Now the information that you try to represent will be different. XML usually represents data. Similar to what you would find in a database, but it kind of looks like HTML.

    Since XML is a simple but exact standard set of rules its easy for 3rd party software makers to tools that utilize the XML standard just like IE can render HTML based on the HTML standard.

    So then you hear about all these different things like XLink, XQuery, XSLT, Schema's, XHTML etc... that are based on or use XML. And it tends to starts overloading you with information.

    In reality these tools like XSLT and XQuery do things when these standards are built into a program. They have exact rules and if you follow the rules when you design an application like IE then your product is complient with these things, just like Firefox is complient with the HTML standard.

    So XSLT for example is a tool that takes XML which looks like a bunch of database data in HTML format to the naked eye and gives rules on how to represent the data as HTML (or any other format you define) but in the context of this example HTML.

    For a further example you might create the page then use XSLT commands to say to loop through the data and display the information in a table and make certain fields certain colors etc... And if you use these XSLT sheets in an XSLT complient program such as IE then it will interpret this information.

    Another type of language is XQuery. You can use that language like you might use SQL to extract information from a set of XML data (which again looks alot like a bunch of data in HTML format). If your application like IE supports XQuery then those commands do things just like Javascript commands do things when your using a browser that supports that.

    So how does this all come together?

    Well you could have some XML data in one file (remember it just looks like a bunch of data represented like HTML)

    Then you can create an XSLT sheet that describes where its getting it's data (Your XML file) and commands to do things like loop through every instance of an element type. Placing those elements within HTML using XSLT commands. You could think of it as providing your XML output as layout in HTML

    Then you might also have a CSS (Style Sheet) that tells your finished document how you would like to display the HTML tags that are produced from your XSLT sheet that produces its output from XML.

    Then consider that this same format can be used to do so many different things (Just like databases can be used for so many different things).

    Amazon uses XML to store all its data. So based on that most programming languages and even browsers now can intelligently manage the data. In fact Amazon supports something known as SOAP.

    SOAP is another set of rules on how to transport XML data from two conduits (ie. programs or scripts) So in this sense Amazon can store all their data in XML, have connectivity to SOAP and the programmer has all sorts of power to more easily access the information.

    For example with programming languages like C#, ASP, PHP, Java etc... that support SOAP you can just use simple commands to get at the data. Just like with SQL you can use simple commands to get at data in a veriety of databases as long as the engine your using supports that.

    So you see all these terms really just describe a bunch of things that are similar to what your allread familiar with in a sense. But for some reason no one likes to describe something like SOAP being similar to SQL because technicaly there are alot of differences, but for the purpose of making sense of it rather then being 100% exact I think some of these examples should give you an idea of what all this means.

    When you hear a term. Just try to figure out if it is a way of structuring data like XML, VoiceXML etc..., a way to access the data functionaly like you use SQL to access database data, XSLT, XPath etc.. or a way to transport the data like SOAP etc.. (a comparison might be HTTP or FTP)

    Hope this helped make sense of things rather then confuse the issue.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •