Navigation HTML with Scala

I want to open a html Source with Scala and then navigate. I new to Scala, so my question is what is the best class to use to navigate. Where I would have methods like getFirstChild?

//get html
val html = Source.fromURL("https://www.google.com")
// now what?

Answers


HTML document is an xml document, so you can use scala capabilities to working with xml. Here is an article which gives basic overview of XML processing capabilities of scala. Of course, There are plenty of java/scala libraries which simplify standart scala mechanism.


AFAIK, Scala doesn't have direct support for HTML ( although it has support for XML in built ). For example:

scala> import scala.io.Source
scala> import scala.xml.XML
scala> val html = Source.fromURL("https://www.google.com")
scala> XML.loadString(html.toString)
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)

This is because all HTML documents are not well formed XML documents. To overcome this, you can use any HTML processing library in Java. Check for an example here:

http://alvinalexander.com/scala/scala-html-parsing


Need Your Help

How can I make my ListView row look like the Twitter app ?

java android listview twitter relativelayout

I am building a Twitter type client. Here is what my ListView row looks like

Jquery Sortable with linked lists inside overflow enabled container

javascript jquery html css jquery-ui-sortable

Alright, so I have a strange problem with the Jquery sortable plugin. I am trying to make a series of lists inside an overflow-y:auto div. This works great when the lists are smaller then the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.