-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scala.js cannot load XML #198
Comments
The Java parser that the scala-xml library depends on isn't available from Scala.js at run time. Note that if it's a literal string you're trying to parse, you should be able to use Scala's XML syntax to just declare your XML literal. |
is this a feature an interested contributor could add...? (by substituting some JS thing for SAX?) |
@ashawley and if it's not a String literal? |
fwiw, at #109 (comment) , @OlivierBlanvillain suggested using fastparse (https://github.com/lihaoyi/fastparse/blob/master/scalaparse/shared/src/main/scala/scalaparse/Xml.scala) |
also relevant: #194, which suggests adding getting-started doc for Scala.js that would presumably cover this |
I don't mind using |
Perhaps, |
Outside of |
You might try this. (And be the first, I guess, it's tested once in scala.js): |
Coursier does something https://github.com/coursier/coursier/blob/9d0b191f0d97e055384ea94f850b98fb501a8cb1/modules/core/js/src/main/scala/coursier/core/compatibility/package.scala, but I suspect it's not aware of the XML namespace - coursier/coursier#1821 |
I am working on doing this, with scalajs-dom, but running into a few issues. Just thought I would mention it here, opening separate issues, |
👍 I understand that @odenzo's solution uses scala-js-dom. This would work in browsers only (not Node.js), so IMO it would make most sense as a separate module within this repo. scala-js-dom is very nearly a stdlib for the Scala.js ecosystem, and I can vouch for its stability as a maintainer, so I think it would be an acceptable dependency to take on here. Edit: btw, I'd be happy to review such a PR. |
FYI fs2-data has just released an integration with scala-xml including a pure Scala, streaming XML parser. Therefore it is fully supported on JVM and JS! |
I'm attempting to parse XML from a String in Scala.js and I get this compile-time error:
The text was updated successfully, but these errors were encountered: