Adding elements

You can add elements to a resource by copying them from one resource and inserting them into the current one, or by using a Module for the XML structure (see chapter "Creating Modules from XSD files").

Adding elements

The content of the file books.xml is edited after being loaded into the resource xmlResource. A new book element with sub elements and values is added. The ActionMode is set to Insert.

A CData text is added to the element Review from the loaded resource RevisionText.

Editing XML elements

After you have saved the XML file, the file books.xml will look like this:

<?xml version="1.0"?>

<x:books xmlns:x="urn:books">

<book id="bk001">

<author>Writer</author>

<title>The First Book</title>

<genre>Fiction</genre>

<price>44.95</price>

<pub_date>2000-10-01</pub_date>

<review>An amazing story.</review>

</book>

<book id="bk002">

<author>Poet</author>

<title>The Poet's First Poem</title>

<genre>Poem</genre>

<price>24.95</price>

<pub_date>2000-10-01</pub_date>

<review>Poetic rhymes.</review>

</book>

<book id="bk003"><!--Newly added book-->

<author>Teacher</author>

<title>School book</title>

<genre>Education</genre>

<price>19.95</price>

<pub_date>2012-01-01</pub_date>

<review><![CDATA[This text is inserted from the file "CDataExample.txt" as <CData> Tag]]></review>

</book>

</x:books>

Inserting CData text into XML

The text of a CData file loaded into a resource can be added to an XML resource (see chapters "Open a resource for CData" and "Copying CData section to resource").

Syntax:

{RES[<CData resource name>]}

Copying and inserting XML elements

XML elements can be copied by entering the dynamic value {COPY[resourceID]} into the Value column.

XML elements can be added by entering the dynamic value {INSERT[resourceID]} into the Value column. The INSERT command supports optional parameters for determining insert nodes.

Syntax:

{INSERT[resourceID][Child|Before|After]}

If no parameter is specified, Child will be used by default.

  • Child: XML elements are inserted beneath the selected node, and as the last child element.

  • Before: XML elements are inserted on the same level, before the selected node.

  • After: XML elements are inserted on the same level, beneath the selected node.

  1. The XML file source.xml is loaded into source as the resource.

  2. The XML file target_object.xml is loaded as the resource target_object.

  3. The node Book is copied from the source using the syntax {COPY[Book]}.

  4. The node Book is copied and saved to the resource target_object beneath the Root node as the last child element using the syntax {INSERT[Books]}.

Copy, insert and verify XML element

Copying CData section to resource

If an XML element contains several CData sections, the CData sections can be saved to a resource. The following syntax is used for the CData element:

Syntax:

{COPY[<resourceID>]}

The syntax #<Index> of the XML element name defines the CData section to be copied to the specified resource. The content of the resource can be inserted into another XML element resource, as described above.

In this example, the second CData section of the CData element is copied to the resource CDATA1.

Example - copying CData to resource

The sample file contains a CData section with the text Second.

Example - file containing CData sections

Copying the content of a CData section

If the value Data is used in the Value column, the content (text) of the CData section is copied to a resource.

In this example, the content of the second CData section of the XML element is copied to the resource Text1.

Example - saving CData to string resource