αƞjiβ
αƞjiβ

Reputation: 3246

Scala Play reading XML string

I am sending XML(text/xml) content-type and in Controller is getting String as

`AnyContentAsXml(<SomeTag>....</SomeTag>)`

which should be like

'<?xml version='1.0' encoding='UTF-8'?><SomeTag>....</SomeTag>`

So how I can convert AnyContentAsXml to XML string?

Upvotes: 0

Views: 137

Answers (1)

H&#252;seyin Zengin
H&#252;seyin Zengin

Reputation: 1226

Play has a builtin xml body parser, you can use like

def someendpoint = Action(parse.xml) { request =>
  val elementOpt = request.body \\ "someelement" headOption
}

notice that, request.body is a NodeSeq and can be used to do any xml releated thing.

Upvotes: 1

Related Questions