Okay let me explain my understanding of why to use XML well one use any way.
XML is used to define the structure of a document, what the document should contain but not how it is formatted. So XML is sort of a blue print for how other documents such as HTML, text and PDF should be structured and what information they should contain.
An examle of two ecommerce systems: eshop[a] has a list of products with their prices in an XML file. eshop[b] has set up a deal with eshop[a] to sell eshop[a]'s products on eshop[b]'s website. So using a parser eshop[b] converts the XML file using PHP (or other language) into HTML to display the products and prices that eshop[a] has to offer. Then when eshop[a] updates the XML file the information is automatically updated on eshop[b]'s website.
Is this how it all works, generally... basically...? Am I right?
Your first paragraph sounds like you're describing XML DTD, but XML is more than just a DTD system. Like your second paragraph describes, it can also be a document its self (with or without DTD). It's not just for changing into HTML on other sites though. It can, and often is, used purely to transfer data from one system to another without having to worry about compatability. Like between two otherwise incompatible databases for example.
I think of XML as a text-based database management system. While it's possible the database you define via XML could simply be a document, it could also be a product inventory, a project calendar, a description of the human genome, or any other data that can be organized in a hierarchical manner. Like any other database, you then have the option of using various methods to extract the particular data that interests you at the moment and format it however you'd like.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation