How Do I Modify an Existing XML Document? (Magic xpa 4.x)
Once an XML document has been created, and the XML views are set up, you can access it much as you would ISAM or SQL tables. Most of the underlying record handling is handled automatically.
You can work with parent records just as you would any other table. The usual Create, Modify, and Delete modes work as they would with any data source. In this example, we just used Ctrl+G to create a Browse program and added a few test records. We don’t do anything with the NodeId and ParentId fields (See How Do I Update the NodeId and ParentId?).
Note that these “top level” records, however, are not the root record for an XML document. In our example, we are accessing the Studio List, which in an ISAM or SQL system would not be considered a child record, but in our XML document, it is just one element of the Productions XML document. The root record, “Productions” must be written before we can add record. See How Do I Create an XML Doc from Scratch.
Now, when you are creating child records, how do you link them to the parent? There are two steps to this.
First, when you are creating the XML View, include the “linking field” in the view for the child record.
You select the linking field you want to use by:
-
Positioning the cursor on the element in the parent level you want to use for linking.
-
From the right-click menu, select Include in View.
Now the linking field will be included in the view. In this example, the “sn” (serial number) field of the title is selected in the child record. Magic xpa adds a forward slash in front of the name to indicate that it is a linking field.
Now, when the record is used in a subtask, the linking field will be automatically updated by Magic xpa.
In this example, we use a parameter for a range, to show only the stars that relate to this movie, which is how most child task views work. But, there is no init on the /sn field. Nonetheless, when the program runs, the /sn field is initialized to the parent sn that was used for the range.
The Online and Rich Client Samples projects (program XM06 and RXM06)