I'm not sure when to use one method versus the other.
XML#loadString
scala> val xml = """<script type="text/javascript">
| | foo("{bar}");
| | </script>"""
xml: String =
<script type="text/javascript">
| foo("{bar}");
| </script>
scala> scala.xml.XML.loadString(xml)
res0: scala.xml.Elem =
<script type="text/javascript">
| foo("{bar}");
| </script>
Source#fromString
scala> scala.xml.Source.fromString(xml)
res1: org.xml.sax.InputSource = org.xml.sax.InputSource@4a183d02
However, I got null when doing:
scala> res1.getByteStream
res2: java.io.InputStream = null
So, I have 2 questions:
- when to use Source#fromString versus XML#loadString
- how to print out/use the InputSource from Source#fromString
Thanks.