Reading XML nodes with dynamic names
Sometimes, the name of an XML node can contains itself data information.
In this case, the name of the node will vary on each file, on each occurrence or execution.
Semarchy xDI’s XML technology offers the possibility to read easily this kind of nodes by specifying a name pattern in the XML Metadata.
For instance, the name of the node below is the name of the person:
<mgt:hotelManagement xmlns:com="http://example.com/samples/common" xmlns:mgt="http://example.com/samples/management" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<GIBBS customerId="1" firstName="Jason" lastName="GIBBS" titleCode="Mr"/>
<JIMENEZ customerId="3" firstName="Tony" lastName="JIMENEZ" titleCode="Mr"/>
<HAMPTON customerId="4" firstName="Lionel" lastName="HAMPTON" titleCode="Mr"/>
</mgt:hotelManagement>
Metadata Configuration
To read XML files containing nodes with varying names, simply:
-
Open the Metadata
-
Navigate to the node
-
Set its Name Selection Pattern
This parameter is waiting for a regular expression.
At read, if the name corresponds to the regex specified here, the Runtime will load the node.
That’s all, you’re ready to load nodes with dynamic names!