<xml>

XML content wrapper processor

Core v2.2.0

Overview

The processor wraps XML content for explicit declaration and processing. Rarely needed in modern configurations - most XML is processed directly without this wrapper. Useful when you need to ensure XML content is properly parsed and validated.

Usage Examples

Example 1: Explicit XML declaration

example-1.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="xmlData">
  <xml>
    <products>
      <product id="1">
        <name>Laptop</name>
        <price>999.99</price>
      </product>
      <product id="2">
        <name>Mouse</name>
        <price>29.99</price>
      </product>
    </products>
  </xml>
</def>
</config>

Example 2: Dynamic XML generation

example-2.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="productName">WebHarvest Pro</def>
<def var="productPrice">199.99</def>

<def var="productXml">
  <xml>
    <product>
      <name>${productName}</name>
      <price>${productPrice}</price>
      <timestamp>${new Date()}</timestamp>
    </product>
  </xml>
</def>
</config>

Example 3: XML template with processing

example-3.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="userData">
  <xml>
    <user>
      <id>12345</id>
      <name>John Doe</name>
      <email>john@example.com</email>
      <preferences>
        <theme>dark</theme>
        <language>en</language>
      </preferences>
    </user>
  </xml>
</def>

<!-- Process the XML -->
<def var="userName">
  <xpath expression="//name/text()">
    <get var="userData"/>
  </xpath>
</def>
</config>

Example 4: When explicit XML is useful

example-4.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<!-- When you need to ensure XML is properly parsed -->
<def var="configTemplate">
  <xml>
    <configuration>
      <database>
        <host>localhost</host>
        <port>3306</port>
        <name>webharvest</name>
      </database>
      <api>
        <baseUrl>https://api.example.com</baseUrl>
        <timeout>30000</timeout>
      </api>
    </configuration>
  </xml>
</def>

<!-- Alternative: Direct XML (usually preferred) -->
<def var="configTemplate2">
  <configuration>
    <database>
      <host>localhost</host>
      <port>3306</port>
      <name>webharvest</name>
    </database>
  </configuration>
</def>
</config>

Parameters

Important Notes

Related Processors