Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Explain Xml

  • 07-06-2012 12:33pm
    #1
    Closed Accounts Posts: 3,513 ✭✭✭


    Can someone explain to me the uses for XML, say for example I have created a website for a bookshop using Notepad++, HTML and CSS can anyone tell me what I could use xml for on this website.

    I have looked into it and can see how it displays certain information using xsl but cant see any difference between this and HTML using CSS?


Comments

  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    I hope I do this justice :)

    In your example you could define an XML type as a "Book". The book would have specific elements - title, author, isbn, price (for example).

    Your CSS can determine how each attribute is displayed - for example, the title is always in bold.

    Doing it in HTML is a bit more manual. If you already have a database of books, you can import it directly into XML, saying that the title field in the database = title attribute in your XML.

    Later on you realise that you want to add a synopsis section for each book. If you've created the list in HTML you have to go back to each line of code and add the synopsis in the right place. With XML you can redefine the schema and add a "synopsis" attribute, then use an XML editor to dump in the synopses for each book.


  • Closed Accounts Posts: 3,513 ✭✭✭donalg1


    Thoie wrote: »
    I hope I do this justice :)

    In your example you could define an XML type as a "Book". The book would have specific elements - title, author, isbn, price (for example).

    Your CSS can determine how each attribute is displayed - for example, the title is always in bold.

    Doing it in HTML is a bit more manual. If you already have a database of books, you can import it directly into XML, saying that the title field in the database = title attribute in your XML.

    Later on you realise that you want to add a synopsis section for each book. If you've created the list in HTML you have to go back to each line of code and add the synopsis in the right place. With XML you can redefine the schema and add a "synopsis" attribute, then use an XML editor to dump in the synopses for each book.

    Thanks for that.

    Another question for you!! If I have an excel spreadsheet with all the books listed, with your headings above can I import this into Excel or would it have to be an access database or similiar database.

    Also if I import this to XML and add to it in future will the additions be automatically added to the web page.


  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    donalg1 wrote: »
    Thanks for that.

    Another question for you!! If I have an excel spreadsheet with all the books listed, with your headings above can I import this into Excel or would it have to be an access database or similiar database.

    Also if I import this to XML and add to it in future will the additions be automatically added to the web page.

    Getting a little out of my comfort zone here, so hopefully someone will come along and correct me if I get things arseways.

    AFAIK, once you've used your XML editor to add the synopses, you should only have to redefine the schema in one or two places (i.e. add the ...attribute: Synopsis.... line into it) and that should flow through to everywhere else.

    I'm pretty sure you can use Excel (you can definitely import into it, and this article suggests you can export from it: http://office.microsoft.com/en-us/excel-help/export-xml-data-HP010206401.aspx?CTT=1)

    If you export from Excel to XML, and then make changes to the Excel file, you'll probably have to export it again. It's probably possible to have your website "running" from the Excel file, but that would be pretty slow and crappy, so don't do that ;)


  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    This tutorial may help explain a bit more:

    http://www.w3schools.com/schema/default.asp


  • Registered Users Posts: 92 ✭✭Jennyrose


    A lot of web data transfer services use XML. Rss feeds are XML.


    For XML files that would be continually changing you would build them in a script that queried your database on demand.

    Mobile apps tend to use either JSON or XML when calling up data and lists of data from servers and APIs?

    Effectively XML is a way of structuring and transferring data over the net whereas HTML is for presentation


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,082 ✭✭✭Feathers


    donalg1 wrote: »
    I have looked into it and can see how it displays certain information using xsl but cant see any difference between this and HTML using CSS?

    So XML stands for eXtensible Markup Language — meaning that instead of using a fixed set of tags & attributes like HTML, you can use whatever structure you want — it's extensible!

    This makes it great for storing data, as you define your own structure, just like you would if you were making a database, like in MySQL. You also get things like XPath, which allow you to query an XML doc & returning all matching nodes.

    The syntax of XML is more strict than HTML, but if you write HTML in the same style, it can be considered perfectly valid XML — this is called XHTML or (X)HTML.

    One example of the more strict syntax would be the line-break tag: <br>. In XHTML, this would have to be written as <br/> to be valid. This is because in XML if you have a tag that doesn't have a matching closing tag for it, it must close itself (the extra backslash).


  • Registered Users, Registered Users 2 Posts: 4,081 ✭✭✭sheesh


    When you hear XML think Database

    Heres why.

    A database is used to store data.
    Databases give data structure (so it can be searched efficiently).
    Databases Describe (or can describe) the data they they store.

    XML Does all that but because its a text file it can be read by all computers

    XML is used by computers to transfer data between different systems.

    XML is markup language like html but the difference is that there are no set tags the tags can be something that describes the data.

    thats my take on it any way :D


Advertisement