Understanding XML

Worked Example: XML and XPaths

28 views October 24, 2018 October 24, 2018 admin 0

For more information introducing key XML concepts please read our Introducing XML files guide.

Sample catalogue layout

 

Sample catalogue XML

The following XML file is typical of the data required to create the simple catalogue table shown.

XPath Reference

Working sequentially down the XML file, the following fields would need to be created within the corresponding EasyCatalog panel.

The XPaths shown are relative to the /Catalogue/MainCategory/Category/SubCategory/Products/Product record XPath.

Field Name XPath Sample Data
MainCategoryName ../../../../@CategoryName Switches & socket outlets
MainCategoryID ../../../../@CategoryID 101
MainCategorySortOrder ../../../../@CategorySortOrder 1
CategoryName ../../../@CategoryName Simplo light switches
CategoryID ../../../@CategoryID 201
CategorySortOrder ../../../@CategorySortOrder 1
SubCategoryName ../../@CategoryName Easy use light switches
SubCategoryID ../../@CategoryID 301
SubCategorySortOrder ../../@CategorySortOrder 1
ProductInstanceID @ProductInstanceID 123
ProductCode @ProductCode E5145
ProductSortOrder @ProductSortOrder 1
Description ProductAttributes/Description/text() Rocker switch, single, 10A
Colour ProductAttributes/Colour/text() WH
Voltage ProductAttributes/Voltage/text() 240
Amps ProductAttributes/Amps/text() 10
RRP ProductAttributes/Pricing/@RRP 6.13
Trade ProductAttributes/Pricing/@Trade 3.68

 

Was this helpful?