module xmlhelper.xml_tree
¶
Short summary¶
module pyrsslocal.xmlhelper.xml_tree
parsing XML
Classes¶
class |
truncated documentation |
---|---|
Overloads functions about XML, it produces objects at the end we assume the file contains a list of objects. |
|
To use a parser like an iterator. Example: |
Methods¶
method |
truncated documentation |
---|---|
prepare the StringIO stream |
|
Adds characters. |
|
After a tag. |
|
Parses an XML document from a URL or an InputSource. |
|
When enters a section. |
Documentation¶
parsing XML
- class pyrsslocal.xmlhelper.xml_tree.XMLHandlerDict(no_content=False)¶
Bases:
ContentHandler
Overloads functions about XML, it produces objects at the end we assume the file contains a list of objects.
- Parameters:
no_content – avoid loading the content of every record
- __init__(no_content=False)¶
- Parameters:
no_content – avoid loading the content of every record
- _prepare_stringio()¶
prepare the StringIO stream
- characters(content)¶
Adds characters.
- endElement(name)¶
After a tag.
- startElement(name, attrs)¶
When enters a section.
- class pyrsslocal.xmlhelper.xml_tree.XMLIterParser(namespaceHandling=0, bufsize=131072)¶
Bases:
ExpatParser
To use a parser like an iterator. Example:
zxml = """ <mixed engine___="conf1" fid="3" grade___="Fair" query___="queryA" rank="3"> <urls> <url___>http://www.shop.com/Soloxine_1_0mg_Tab-181378988-214010464-p!.shtml</url___> <url___>http://fake</url___> </urls> </mixed> <mixed engine___="conf1" fid="4" grade___="Good" query___="queryA" rank="4" url___="http%3A//www.lamars.com/products/nutrition.html" /> """ zxml = "<root>%s</root>" % zxml f = StringIO.StringIO (zxml) assert len(f.getvalue()) > 0 parser = XMLIterParser() handler = XMLHandlerDict(no_content = False) parser.setContentHandler(handler) nb = 0 for o in parser.parse(f) : assert o["query___"] == "queryA" nb += 1 assert nb > 0
- __init__(namespaceHandling=0, bufsize=131072)¶