Tag Archives: xml

SQL – Select into XML structure

select 
d.sup_productCode
,m.tpi_familyCode
,m.tpi_propertyCode
,d.sup_propertyValue
,m.map_type
,d.sup_familyCode
,d.sup_propertyCode
,m.note
from imp_dataSource d
join def_mapping m on m.sup_propertyCode = d.sup_propertyCode
where m.sup_familyCode = d.sup_familyCode or m.sup_familyCode ='GENERIC'
and m.map_type in ('SIMPLE', 'COMPLEX')
and d.sup_propertyValue != '' and d.sup_propertyValue is not null
order by d.sup_familyCode, d.sup_productCode, d.sup_propertyCode
for xml auto, type, elements, root('Products')
Advertisements

XPath Example – Attributes

This line will find the familyName attributes and thier values in TradeXML:

/TP3Message/BusinessMessage/TP3CatalogUploadRequest/TP3CatalogUploadRequestItems/Product/PIData/ProductFamily/@familyName

This line will find the values of nodes where attribute ‘name’ = ‘subject’:

/TP3Message/BusinessMessage/TP3CatalogUploadRequest/TP3CatalogUploadRequestItems/Product/OtherData/Assets/Asset/AssetProperty[@name='subject']