Where does XML fit in relation to website and webpages?

In summary, the conversation discusses the differences between HTML and XML and how they are used in the context of the internet and the web. HTML is used specifically for creating web pages, while XML is focused on accurately describing complex information. XML files can be sent along with HTML files when creating a webpage, and they are often used for storing large amounts of data that can be accessed through a JavaScript XML parser. JSON is another format that is commonly used for data exchange, and it is similar to XML in that it uses a text format. SVG, a vector graphics format, is essentially an XML file. Overall, both HTML and XML have their own purposes and can be used together to create dynamic and informative web pages.
  • #1
fog37
1,569
108
TL;DR Summary
understanding the use of XML
Hello,

I understand that webpages are created using HTML which defines the structure of the document using a finite number of specified tags, like <p>, <head> etc.

In XML, the user can create customized tags (as long as certain rules are respected). The XML file recipient must then be able to interpret those custom tags. But where does a XML file play a role in the context of the internet and the web?
Webpages, written in HTML, are generally uploaded to servers and then viewed by the client's browser. A XML file more clearly specifies the content type of a document so a human going through the file can more clearly understand. XML files are read using XML parsers...
Is a XML file sent along with the HTML file when a webpage is created?

Thank you!
 
Technology news on Phys.org
  • #2
They are two distinct formats for documents. HTML is specifically geared to web pages whereas XML is focused on accurately describing complex information and its attributes. As an example, a spreadsheet might be represented as an XML file and can be imported into a spreadsheet tool. The xml tagging describes the data sufficient for the spreadsheet tool to import it. Typically there would be no rendering tags like preferred fonts for some field or preferred color instead it would describe the fields units of measure or whatever was needed.

XML is good at conveying binary data in textual format as sometimes binary would get corrupted when being transmitted over the network as part of a document.

Here's a more descriptive difference between them:

https://courses.cs.vt.edu/~cs1204/XML/htmlVxml.html

Here's a bloggers article on the differences and intents:

https://www.upgrad.com/blog/html-vs-xml/#:~:text=HTML and XML are related,language that defines other languages.
 
  • Like
Likes jim mcnamara
  • #3
I feel like Wikipedia has all the answers to your questions. If you look at the list of XML markup languages, I would bring your attention to RSS, SVG, or MathML for examples of how it can be used in the context of the web.
 
  • Like
Likes sysprog and jedishrfu
  • #4
fog37 said:
Is a XML file sent along with the HTML file when a webpage is created?
It can be. When I am producing webpages that contain a lot of data, I will often store the data in an XML file, then access it from the HTML page using a JavaScript XML parser.

Actually, more often I'll use JSON

Sample JSON:
{
    "title": "Dave's Biography",
    "columns": [{
        "header": "Year",
        "rows": [
            1964
        ]
    },{
        "header": "Month",
        "seasons":[{
            "title": "Jan-Mar"
        },{
            "title": "Apr-Jun"
        },{
            "title": "Jul-Sep"
        },{
            "title": "Oct-Dec"
        }]
...
 
Last edited by a moderator:
  • Like
Likes fog37 and jedishrfu
  • #5
This is in XML/SVG; not in HTML: https://media.inkscape.org/media/resources/file/Koi_carp_2.svg

The browser can display it as if it were an image/animation, but it's in fact a text file -- you can download it, edit the text, and then check out the effects of the edits by loading the new version into the browser.

XML allows association of semantic context with raw data.
 
  • Like
  • Informative
Likes Mark44, fog37 and jedishrfu
  • #6
DaveC426913 said:
It can be. When I am producing webpages that contain a lot of data, I will often store the data in an XML file, then access it from the HTML page using a JavaScript XML parser.

Actually, more often I'll use JSON

Sample JSON:
{
    "title": "Dave's Biography",
    "columns": [{
        "header": "Year",
        "rows": [
            1964
        ]
    },{
        "header": "Month",
        "seasons":[{
            "title": "Jan-Mar"
        },{
            "title": "Apr-Jun"
        },{
            "title": "Jul-Sep"
        },{
            "title": "Oct-Dec"
        }]
...
Thanks DaveC42913.

So it is a data-exchange format to send data in a text format. JSON does the same thing. What do you mean when you say "producing webpages that contain a lot of data"? What kind of data? Can you give me an example?
My basic understanding is a webpage with HTML, CSS, and JS. What other kind of data?

I did read that SVG, which is a vector graphics format, is essentially an XML file.

As far as JSON, I read that converting data to JSON and vice versa is called serialization/deserialization and a JSON file is called a "string"...like a sequence of bytes? Every transmitted file is a sequence of bytes...
 
  • #7
I defer to what @jack action said, as the full answers are pretty big, much too lengthy to be presented here . . . maybe look up xhtml to start delving . . .
 
  • #8
@fog37: I think that @DaveC426913 is referring to dynamically generated web pages (including with dynamically-fetched scripts) -- if you have a static page, any data on it is probably less up-to-the-minute than that which on a dynamic page would be -- XML stored procedures (and html with javascript) can include SQL stored procedures -- if you're designing a page that presents, e.g., the daily news, you might want your javascript code to consult and present parts of a database, so that the web page is newly made for the daily news purpose.
 
  • #9
fog37 said:
where does a XML file play a role in the context of the internet and the web?
It doesn't, really (except for the case where XML is used in Javascript to send data back and forth between browser clients and servers using AJAX), but there was a movement years ago to push adoption of the XHTML specification, which was a form of HTML that was also valid XML. If this movement had succeeded, web pages fetched by your browser would have been valid XML documents.

The main reason this movement failed is that XML, as a data format, is extremely specific and intolerant of variation, and most people who are writing web content simply don't want to deal with all the extra fuss of having to have every web page they write meet an extremely specific, variation intolerant specification. They just want to write web pages. HTML (and in particular HTML 5, the current version) is much looser than XML and is much easier for web page writers to work with, particularly ones who don't have a lot of time to spend worrying about the precision of their document formats.
 
  • Like
Likes fog37 and sysprog
  • #10
fog37 said:
As far as JSON, I read that converting data to JSON and vice versa is called serialization/deserialization
This is true of data in any format, not just JSON. The data your computer program works with is not the same as the data that gets stored on disk or sent over the network. Converting between the two is therefore necessary, and that's what serialization/deserialization is.

fog37 said:
a JSON file is called a "string"
It is? Where?

fog37 said:
...like a sequence of bytes? Every transmitted file is a sequence of bytes...
Every file, period, is a sequence of bytes. It doesn't matter what format its data is supposed to be in.
 
  • Like
Likes fog37
  • #12
One relationship between XML and HTML is also XLST, a way to directly convert a XML file into HTML for display for instance.

Years ago I used that quite a lot make computer generated output nicely displayable in the browser when opened or viewed. I remember one case with a traffic train position information being generated as XML, tagged with a XLST stylesheet and then displayed as a stylized track-map with "moving" train symbols when viewed by the public info display on each station.
 
  • Like
  • Informative
Likes fog37, jack action and sysprog
  • #13
A json file is called a string

Most of web programming is just "Put the thing on the string". Dr Seuss would have made a good web programming textbook. EDIT: I mean, what is a web page?
 
Last edited:
  • Like
Likes fog37
  • #14
fog37 said:
What do you mean when you say "producing webpages that contain a lot of data"? What kind of data? Can you give me an example?
My basic understanding is a webpage with HTML, CSS, and JS. What other kind of data?
Here is an example:
https://davesbrain.ca/science/plates/index.html
(optimized for Chrome, other browsers may produce ... unpredictable results)
I was tracking license plates spotted on the road in an attempt to predict the first appearance of DAVE plates.
(predicted to first appear on Ontario roads in June of 2025)

As a web dev, I was taught to keep data and presentation separate. So all the data is in a file called data/plates.json, like this:

Code:
[
  {
    "plate": "CAA",
    "date": "2016-10-18",
    "tags": [ "section", "unreliable" ]
  },
  {
    "plate": "CAB",
    "date": "2016-10-18",
    "tags": [ "unreliable" ]
  },
  {
    "plate": "CAC",
    "date": "2016-10-18",
    "tags": [ "unreliable" ]
  },
 
. . .

  {
    "plate": "CEB",
    "date": "2018-01-16"
  }]

You can browse my files and code by pressing F12 while on the page. That will open the developer window.
(Some of it may not make sense because I was in the middle of adding Angular to render the line graph at the bottom.)

The convenience of doing it this way is that I don't need to involve a hugely complex and server-dependent database layer. My data/renderer page is
- entirely self-contained
- easily portable
- future-proof
- server and host agnostic
- text-only (and therefore trivial to update regularly)
(I have had problems in the past with my works rotting over time, as they move from server to server and/or webhost to webhost).Here is an example of a data-heavy page that has rotted as browsers updated their specs:
https://davesbrain.ca/science/mars_atlas/index.html
The buttons all work, but you can see (if you turn on "labels") that the white labels for surface features are all mashed into the upper left corner of the map.
 
Last edited:
  • Like
Likes fog37 and anorlunda
  • #15
Filip Larsen said:
One relationship between XML and HTML is also XLST, a way to directly convert a XML file into HTML for display for instance.
XSLT is not a way to convert XML to HTML. It's a way to transform an XML document into a different XML document. If the XML you transform to happens to be valid HTML (or even invalid HTML that is invalid in a way that enough people have done that it's worth the effort for browsers to understand it), then a web browser will be able to parse and display it. But that is by no means the only use case for XSLT.
 
  • Like
Likes fog37 and sysprog
  • #16
PeterDonis said:
XSLT is not a way to convert XML to HTML. It's a way to transform an XML document into a different XML document.
Which can then be (some, but not arbitrary) HTML. I still think "XLST is one way to convert XML to HTML" is a valid first-order approximation in the context of what the OP asks.
 
  • Like
Likes fog37 and sysprog
  • #17
Filip Larsen said:
I still think "XLST is one way to convert XML to HTML"
Yup. Built "Operation Migration" 's* website that way.

*Yah. The guy with the ultralight and the geese.
 
  • Like
Likes fog37

FAQ: Where does XML fit in relation to website and webpages?

What is XML and how does it relate to website and webpages?

XML, or Extensible Markup Language, is a versatile and popular markup language used to store and transport data. In relation to websites and webpages, XML is often used to structure and organize data for easier manipulation and sharing across different platforms.

Can XML be used to create a website or webpage?

No, XML is not a programming language and cannot be used to create a website or webpage on its own. However, XML can be used in conjunction with other languages, such as HTML and CSS, to create dynamic and interactive webpages.

How is XML different from HTML?

XML and HTML are both markup languages, but they serve different purposes. HTML is used to structure and display content on a webpage, while XML is used to store and transport data. XML is more flexible and customizable, allowing developers to create their own tags and define their own document structure.

What are the advantages of using XML in web development?

XML has several advantages in web development. It allows for structured data storage and easy data sharing between different applications and platforms. XML also allows for easier data manipulation and processing, making it useful for creating dynamic and interactive webpages. Additionally, XML is human-readable and can be easily understood and edited by developers.

How does XML fit into the modern web development landscape?

XML is still widely used in modern web development, particularly for data storage and transfer. However, it has been largely replaced by other technologies such as JSON and YAML, which offer simpler syntax and better performance. XML is still used in certain industries and applications, but it is not as prevalent as it once was in web development.

Similar threads

Replies
22
Views
1K
Replies
17
Views
2K
Replies
4
Views
2K
Replies
15
Views
2K
Replies
14
Views
2K
Replies
4
Views
3K
Replies
1
Views
1K
Replies
14
Views
1K
Back
Top