How Do I Create an XML View? (Magic xpa 4.x)
The XML view is the key to working with XML in Magic xpa. Once the XML view is created, you can work with the XML document much as you would any other Data Source in Magic xpa.
Prerequisite: You need to have:
-
Open up a line in the Data repository (F4, or Edit->Create Line).
-
Set the Database column to a database that has a Data Source type of XML File.
-
Get the schema information by selecting Options->Get Definition (F9). A file selection dialog box will open, which allows you to select the schema .xsd file.
When you select the .xsd file, the Name, and Data source name fields will default to the first element in the schema, which in this example is “Productions”.
-
The View tab will be filled in automatically from the information in the .xsd.
You might see only the complex elements (The ones with the ‘+’ icon). To show the simple elements also, select Right-Click->Show Simple. In the picture below, we are showing the simple elements (and the menu changes to Hide Simple).
-
Since we want to create a view into the Title element, we move to the Title element, and select Right-click->Include in View.
Now, you have a sub-element that is linked to the root element by the NodeId and ParentId.
-
Change the Data Source Name to reflect the name of the actual XML document that will hold the data. It’s a good idea to use logical names or relative paths rather than hard-coding the path name.
-
Change the Name to anything you like, to reflect what you want to call this XML view.
Now you can access the TitleList much as you would any other data source.
Note: You will need to create one XML view for each repeating element in the XML document (see How Do I Access a Certain Compound in an XML File?). Also, you need to initialize the root element before you can write to the XML document (see How Do I Create an XML Doc from Scratch?).
-
Go to the title (#) of the Data repository and open the Get Definition screen (F9, or Options->Get Definition).
-
Switch to the XML tab.
-
Set the Database to a database that has a Data Source type of XML File.
-
Select the schema and click OK.
The new views will be added to the Data repository (and optionally the programs will be added to the Program repository).
The Online and Rich Client Samples projects (program XM03 and RXM03)