jahilldev
jahilldev

Reputation: 3812

Scala Lift - LiftRules.loadResourceAsXml extract value

I have the following:

LiftRules.loadResourceAsXml("/config.xml")

I'm trying to extract values from the following xml sheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<config>

    <webroot>/opt/tomcat/webapps/ROOT</webroot>
    <broadcast>

        <quality>

            <primary>15</primary>
            <secondary>2</secondary>

        </quality>

    </broadcast>

</config>

Thanks in advance for any help, much appreciated :)

EDIT : Added root tag

Upvotes: 1

Views: 127

Answers (1)

Rogach
Rogach

Reputation: 27250

Here's an example on extracting primary quality from that config:

val primaryQuality: Int = LiftRules.loadResourceAsXml("/config.xml").map { x =>
    (x \\ "quality" \ "primary" head).text.toInt
} openOr 20

Upvotes: 1

Related Questions