Introduce yourself to XML before Maggi cooks.

Ehth77
Ehth77
Aug 25, 2017 · 2 min read

DISCLAIMER: I don’t work for nestle nor are they paying any royalty for this post. Although it would be nice if they gifted a carton of Kitkats. :p

Before we begin, take heated water in a pan, plop the noodles, fire. (By the end of the article you’ll have something that suits your savour).

First Things first

<?xml version=”1.0" encoding=”UTF-8"?>.

This line speaks for it itself. version and encoding are theattributes of the xml “tag”. This element must be the first thing on the first line. This is analogous to she-bang(yes, like she-bang this is optional).

Tags, attributes, elements

E.g of an XML document(source: https://learnxinyminutes.com/docs/xml/)

Opening tag: <tag-name>

Closing tag: </tag-name>

Open-close tag: <tag-name />

  • It’s mandatory to close them in the reverse order they were opened.
  • They can be nested.(author, year, price and title are nested inside book tag. which in-turn belongs to bookstore tag)
  • Whatever goes between the Open and Close tag are the elements of the tag.(e.g 2003 is the element of year tag)
  • key-value element pairs(written key=”value”) are given along the tag. They are known as “attributes” and the values of the attribute must be quoted.(e.g: lang=”en” is the attribute of title.)Note: attributes can’t be nested.
  • Tag-names are case-sensitive and can only contain alphanumeric chars and underscore.(The first character must be an alphabet).
  • <!--whatever goes in here is a comment.-->(see line 2)
  • Reserved characters are escaped using “&;”. &lt; escapes lesser than.
  • XML reserves no tag-names that means you can come up with any name you want and get-away with it.

That’s all you need to know to read an XML document. The rules for XML is similar to HTML but only stricter. The attitude XML has is “I don’t care about the presentation, give me the contents”.

References

There are things I left out you can refer one of the links(below) for more info.

Consider the alternatives

It’s time for masala and stirring. Thanks for reading and enjoy your Maggi.

P.S: The title for the story is inspired by all the posts which introduce you to some framework/language in Y minutes(where Y= the time it takes to read the post as guess by Medium).

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade