Parsing XML from Strings : XML Parse « XML « Python






Parsing XML from Strings

Parsing XML from Strings
 
from xml.dom import minidom

contents = "<grammar><ref id='bit'><p>0</p><p>1</p></ref></grammar>" 
xmldoc = minidom.parseString(contents)             
print xmldoc.toxml() 
           
         
  








Related examples in the same category

1.Extracting the Ingredients from a Recipe with Regular Expressions
2.Processing XML with Regular Expressions
3.Simple XML Document Analysis
4.Parsing XML from Local Files and Remote URLsParsing XML from Local Files and Remote URLs
5.Parsing XML from a URL
6.Parsing XML: Loading an XML Document