SELECT.XML

  • Updated

 

Selects content from a source containing Xml-format.

Properties

From Name of the Input Data Source. The input-source can contain either a file-path, a PBinaryStream object or a .Net Stream object. A Stream object can only be specified programmatically.
The format of the source must be a text document containing Xml.
To Name of the Output Data Source.
The output-source will always be a neutral Table-format.

Parameters

@Context

Specifies in which context to find data in the Xml document.
Define XPath to locate the root from which the data you are interested in extracting can be found.

Examples:

  • /PRODUCT – Will find the PRODUCT element at the first level
  • /DATA/PRODUCT – Will find the PRODUCT element at the second level below DATA
  • //PRODUCT - Will find any PRODUCT element at any level
  • //PRODUCT* – Will find any PRODUCT element at the second level

Hint
If you cannot find a root from which you can find all the data you are interested in, then split your selection into more steps and use the JOIN Command to assemble the results.

@DefaultNameSpacePrefix If the XML use a Default Namespaces like xmlns="namespaceURI" a prefix must be use in the XPath. Default prefix is “ns”
@Filter Filter the result of the selected data. See Command Maps & Parameters for more information.
@Order Order the result of the selected data. See Command Maps & Parameters for more information.

Map

From XPath to the element or attribute containing the desired value
The XPath must be relative to the root located by the @CONTEXT parameter, e.g.
Example1: 'PRODUCT_DETAILS/EAN'
Example2: 'PRODUCT_PRICE_DETAILS/PRODUCT_PRICE[@price_type='']/PRICE_AMOUNT'
Combining the @CONTEXT and From will together locate the desired value.
It is also possible to select several elements as follows:
Example3: 'PRODUCT_DETAILS/{*}'
To Name of the Header as it should be called in the Output table
If unspecified, the name will be taken from the selected element or attribute containing the desired value. In above example 1 and 2 this will be EAN and PRICE_AMOUNT.
Script Not supported by this Command. If you need to perform any manipulation via script, do this in a following step, by passing the result to another Command such as SELECT or SELECT.UNIQUE.

Example 1

Below example will read the specified parts of an Xml-file in the BMEcat format.

Action Map - From To Command
  XMLTable1 SELECT.XML
/PRODUCT @Context  
PRODUCT_DETAILS/*    
PRODUCT_ORDER_DETAILS/ORDER_UNIT    
PRODUCT_PRICE_DETAILS/PRODUCT_PRICE[@price_type='']/PRICE_AMOUNT PriceAmountDefault
SUPPLIER_PID    

Example 2

Below example is the same as above, but extended, to show how easy it is (with a few extra mappings) to also include all the Feature and Attribute values from the BMEcat-format.

Action Map - From To Command
  XMLTable1 SELECT.XML
/PRODUCT @Context  
PRODUCT_DETAILS/*    
PRODUCT_ORDER_DETAILS/ORDER_UNIT    
PRODUCT_PRICE_DETAILS/PRODUCT_PRICE[@price_type='']/PRICE_AMOUNT PriceAmountDefault  
SUPPLIER_PID    
  XMLFeatures SELECT.XML
/PRODUCT/PRODUCT_FEATURES/FEATURE @Context  
../../SUPPLIER_PID    
FNAME    
FVALUE    
FORDER    
XMLFeatures XMLUNIQUE SELECT.UNIQUE
SUPPLIER_PID    
FVALUE    
XMLUNIQUE XMLTable2 JOIN

Example 3

Example of an XML using Default and Prefixed Name Space

<?xml version="1.0" encoding="UTF-8"?> 
<ROOT xmlns="www.test.com" xmlns:a="www.test.com/a"> 
  <CATALOG> 
    <CATALOG_GROUP_SYSTEM> 
      <a:CATALOG_STRUCTURE type="root"> 
        <GROUP_ID>1234</GROUP_ID> 
        <GROUP_NAME>abcd</GROUP_NAME> 
      </a:CATALOG_STRUCTURE> 
    </CATALOG_GROUP_SYSTEM> 
  </CATALOG> 
</ROOT>

 

Action Map - From To Command
  XMLTable1 SELECT.XML
//ns:CATALOG_GROUP_SYSTEM/a:CATALOG_STRUCTURE @Context  
*    

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.