summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/xml/parsing/ConstructingParser.scala21
1 files changed, 20 insertions, 1 deletions
diff --git a/sources/scala/xml/parsing/ConstructingParser.scala b/sources/scala/xml/parsing/ConstructingParser.scala
index 7d1f06c15f..fafabc916d 100644
--- a/sources/scala/xml/parsing/ConstructingParser.scala
+++ b/sources/scala/xml/parsing/ConstructingParser.scala
@@ -26,7 +26,26 @@ object ConstructingParser {
}
}
-/** an xml parser. parses XML and invokes callback methods of a MarkupHandler
+/** an xml parser. parses XML and invokes callback methods of a MarkupHandler. Don't forget to call next.ch on a freshly
+ * instantiated parser in order to initialize it. If you get the parser from the object method, initialization is already done for you.
+ *
+ *<pre>
+object parseFromURL {
+ def main(args:Array[String]): Unit = {
+ val url = args(0);
+ val src = scala.io.Source.fromURL(url);
+ val cpa = scala.xml.parsing.ConstructingParser.fromSource(src, false); // fromSource initializes automatically
+ val doc = cpa.document();
+
+ // let's see what it is
+ val ppr = new scala.xml.PrettyPrinter(80,5);
+ val ele = doc.docElem;
+ Console.println("finished parsing");
+ val out = ppr.format(ele);
+ Console.println(out);
+ }
+}
+</pre>
*/
class ConstructingParser(inp: Source, presWS:Boolean)
extends ConstructingHandler