How to handle the XML files and fetch the data out of it?
Following is the useful link for studying with good examples.I have learned from it.
https://docs.python.org/2/library/xml.etree.elementtree.html
This is the example XML content given in that link. We can read or process the XML by two ways.
1. Reading XML from the file
2. Giving the whole content as string a variable and then processing it.
Before we do parsing or reading the XML file, we should know how python xml.etree.ElementTree class is gonna understand the XML file.
1. Tree - The whole XML file is called tree (Well structured and organized)
2. Root - The data tag is called as root of the XML file
3. Child - Inside data tag is a Country tag which is called as Child for the root. There may be 'n' of childs possible
4. GrandChild - Inside the country tag other tags like rank, year, gdppc and neighbor are called other tags or grandchild. Thats what I call by myself.
We will be using the tag, attrib and text fetch those contents out of the well formed XML file.
Following is the useful link for studying with good examples.I have learned from it.
https://docs.python.org/2/library/xml.etree.elementtree.html
1 2008 141100 4 2011 59900 68 2011 13600
1. Reading XML from the file
2. Giving the whole content as string a variable and then processing it.
Before we do parsing or reading the XML file, we should know how python xml.etree.ElementTree class is gonna understand the XML file.
1. Tree - The whole XML file is called tree (Well structured and organized)
2. Root - The data tag is called as root of the XML file
3. Child - Inside data tag is a Country tag which is called as Child for the root. There may be 'n' of childs possible
4. GrandChild - Inside the country tag other tags like rank, year, gdppc and neighbor are called other tags or grandchild. Thats what I call by myself.
We will be using the tag, attrib and text fetch those contents out of the well formed XML file.
Comments
Post a Comment