XML/XPath: Difference between revisions

Content added Content deleted
({{omit from|PARI/GP}})
Line 668: Line 668:


xmlfile = file("test3.xml") # load xml document from file
xmlfile = file("test3.xml") # load xml document from file
xmldoc = xmldom.parse(xmlfile).documentElement # parse from file stream or...
xmldoc = minidom.parse(xmlfile).documentElement # parse from file stream or...
xmldoc = xmldom.parseString("<inventory title="OmniCorp Store #45x10^3">...</inventory>").documentElement # alternatively, parse a string
xmldoc = minidom.parseString("<inventory title="OmniCorp Store #45x10^3">...</inventory>").documentElement # alternatively, parse a string
# 1st Task: Retrieve the first "item" element
# 1st Task: Retrieve the first "item" element