C.87 XmlPropertyTask
Prev | Appendix C. Optional tasks | Next

## C.87 XmlPropertyTask

Loads property values from a well-formed xml file. There are no other restrictions than "well-formed".

Table C.117: Attributes

Name | Type | Description | Default | Required
--- | --- | --- | --- | ---
`file` | `String` | The XML file to parse. | n/a | Yes
`prefix` | `String` | The prefix to prepend to each property | n/a | No
`keepRoot` | `Boolean` | Keep the xml root tag as the first value in the property name. | `true` | No
`collapseAttributes` | `Boolean` | Treat attributes as nested elements. | `false` | No
`delimiter` | `String` | Delimiter for splitting multiple values. | , | No
`required` | `Boolean` | If this is set to `true` then a build exception will be raised if the file cannot be found otherwise only a warning will be logged. | `false` | No

### C.87.1 Example

Consider the following XML file:

    <root-tag myattr="true">
        <inner-tag someattr="val">Text</inner-tag>
        <a2><a3><a4>false</a4></a3></a2>
    </root-tag>

Used with the following entry (default):

    <xmlproperty file="somefile.xml"/>

results in the following properties:

    root-tag(myattr)=true
    root-tag.inner-tag=Text
    root-tag.inner-tag(someattr)=val
    root-tag.a2.a3.a4=false

Used with the following entry (`collapseAttributes=true`):

    <xmlproperty file="somefile.xml" collapseAttributes="true"/>

results in the following properties:

    root-tag.myattr=true
    root-tag.inner-tag=Text
    root-tag.inner-tag.someatt=val
    root-tag.a2.a3.a4=false

Used with the following entry (`keepRoot=false`):

    <xmlproperty file="somefile.xml" keepRoot="false"/>

results in the following properties:

    inner-tag=Text
    inner-tag(someattr)=val
    a2.a3.a4=false

Prev | Up | Next
C.86 XmlLintTask | Home | C.88 ZendCodeAnalyzerTask