![]() |
|
Navigation |
Synopsis Parse an XML document and return a DOM instance.
Function
Node parseXMLDOM(str src)
Usage
import lang::xml::DOM;
Examples Read the sample note file, parse it, and construct a DOM instance.
rascal>import IO; ok rascal>import lang::xml::DOM; ok rascal>N = readFile(|courses:///Rascal/Libraries/lang/xml/note.xml|); str: "\<note\>\n\<to\>Jurgen\</to\>\n\<to\>Tijs\</to\>\n\<from\>Paul\</from\>\n\<date\>2012-04-01\</date\>\n\<heading font=\"bold\"\>Reminder\</heading\>\n\<body\>Don\'t forget to run the Rascal tests!\</body\>\n\</note\>" rascal>parseXMLDOM(N); Node: document(element( none(), "note", [ charData("\n"), element( none(), "to", [charData("Jurgen")]), charData("\n"), element( none(), "to", [charData("Tijs")]), charData("\n"), element( none(), "from", [charData("Paul")]), charData("\n"), element( none(), "date", [charData("2012-04-01")]), charData("\n"), element( none(), "heading", [ attribute( none(), "font", "bold"), charData("Reminder") ]), charData("\n"), element( none(), "body", [charData("Don\'t forget to run the Rascal tests!")]), charData("\n") ]))The DOM instance contains every single character (including spaces and newlines) as they appear in the source file. As expected, the result is of type xml/DOM/Node. ![]() |