---
name: "Tree::XPathEngine::Literal"
section: "3pm"
platform: "linux"
package: "libtree-xpathengine-perl"
version: "0.05-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Tree::XPathEngine::Literal"
---

# Tree::XPathEngine::Literal(3pm)

Simple string values.

## NAME

Tree::XPathEngine::Literal - Simple string values.

## DESCRIPTION

In XPath terms a Literal is what we know as a string.

## API

### new($string)

Create a new Literal object with the value in `$string`. Note that &quot; and &apos; will be converted to " and ' respectively. That is not part of the XPath specification, but I consider it useful. Note though that you have to go to extraordinary lengths in an XML template file (be it XSLT or whatever) to make use of this:

```
        <xsl:value-of select="&quot;I'm feeling &amp;quot;sad&amp;quot;&quot;"/>
```

Which produces a Literal of:

```
        I'm feeling "sad"
```

### value()

Also overloaded as stringification, simply returns the literal string value.

### xpath\_cmp($literal)

Returns the equivalent of perl's cmp operator against the given `$literal`.

### Other Methods

Those are needed so the objects can be properly processed in various contexts

- as\_string

  - as\_xml

  - value

  - evaluate

  - xpath\_to\_boolean

  - xpath\_to\_literal

  - xpath\_to\_number

  - xpath\_string\_value
