![]() |
|
Navigation |
Synopsis Parse an XML document and trim it (remove layout).
Function
Node parseXMLDOMTrim(str src)
Usage
import lang::xml::DOM;
Examples Read the sample note file, parse it, and construct a DOM instance (using
parseXMLDOMTrim ).
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>parseXMLDOMTrim(N); Node: document(element( none(), "note", [ element( none(), "to", [charData("Jurgen")]), element( none(), "to", [charData("Tijs")]), element( none(), "from", [charData("Paul")]), element( none(), "date", [charData("2012-04-01")]), element( none(), "heading", [ attribute( none(), "font", "bold"), charData("Reminder") ]), element( none(), "body", [charData("Don\'t forget to run the Rascal tests!")]) ]))All whitespace characters have been removed and do not occur in the trimmed DOM instance. Compare this with the output of parseXMLDOM. ![]() |