How Do I Access a Certain Compound in an XML File? (Magic xpa 4.x)
When you are working with an XML document, you are by definition working with a hierarchical database. Typically an XML document will have several levels. Even though these are stored together, you will work with them as though they were hierarchical data within SQL or ISAM tables.
In our example, the “Productions” XML document has several repeating elements:
-
The root level: Productions, which will have exactly one record.
-
Under Productions, the StudioList, which can have any number of elements.
-
Under Productions, the TitleList, which can have any number of elements.
-
Under TitleList, the Starring list, which can have any number of elements.
You will need one XML view for each level. After that, Magic xpa will do most of the work to keep the hierarchy correct when records are written.
-
Select the node that is one level above the simple elements you want to include.
-
From the right-click menu, select Include in View.
-
For “child” records, you should also include a linking field. See the How Do I Modify an Existing XML Document? topic.
Now, the simple elements will appear as fields in the XML view, and you can access them from a Magic xpa program. See the How Do I Create an XML View? topic for more details.
Note: You can tell the simple elements from the complex elements because the simple elements have an “=” icon in front of them, while the complex elements have a “+”. If the simple elements are not showing on the view, select Show Simple from the right-click menu.
The Online and Rich Client Samples projects (program XM05 and RXM05)