User:Jarle Pahr/XML: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
No edit summary
Line 45: Line 45:
*.attrib: Python dictionary with the elements attributes and their values.
*.attrib: Python dictionary with the elements attributes and their values.


ElementTree methods:
Element.findall(elementtype) : Get all child elements of the type elementtype.
Element.get(name): get the attribute value of the attribute name.
Element.attrib.keys(): Show attribute keys of the element.


Seee also:
Seee also:

Revision as of 15:10, 9 January 2014

Notes on Extensible Markup Language (XML): https://en.wikipedia.org/wiki/XML


http://stackoverflow.com/questions/3536893/what-are-the-pros-and-cons-of-xml-and-json



XML in Python

https://wiki.python.org/moin/PythonXml

http://docs.python.org/2/library/xml.etree.elementtree.html#module-xml.etree.ElementTree

http://www.boddie.org.uk/python/XML_intro.html

http://stackoverflow.com/questions/1912434/how-do-i-parse-xml-in-python

http://oreilly.com/catalog/pythonxml/chapter/ch01.html

https://wiki.python.org/moin/MiniDom

lXML

http://lxml.de/3.3/lxmldoc-3.3.0beta3.pdf#chapter.7

https://pypi.python.org/pypi/lxml

http://lxml.de/3.3/lxmldoc-3.3.0beta3.pdf

http://infohost.nmt.edu/tcc/help/pubs/pylxml/web/index.html

http://stackoverflow.com/questions/4808753/find-occurrence-using-multiple-attributes-in-elementtree-python


The packages ElementTree and lxml uses an "Element Tree" view of .xml files differing from the Document Object Model (DOM).

The Element class in lxml contains the following attributes:

  • .tag: The name of the element.
  • .text: The text inside the element, up to the first child element. Equals None if no text.
  • .tail: The text following the element.
  • .attrib: Python dictionary with the elements attributes and their values.


ElementTree methods:

Element.findall(elementtype) : Get all child elements of the type elementtype.

Element.get(name): get the attribute value of the attribute name.

Element.attrib.keys(): Show attribute keys of the element.

Seee also:

  • SBML
  • JSON