LOCAL OriginalFile AS String TEXT TO m.OriginalFile NOSHOW <?xml version="1.0" encoding="utf-16"?> <Orders> <Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <DeliveryCompanyName /> <DeliveryTitle>Mr</DeliveryTitle> <DeliveryFirstName>First</DeliveryFirstName> <DeliveryLastName>Name</DeliveryLastName> <DeliveryAddress1>64 Zoo Lane</DeliveryAddress1> <DeliveryAddress2></DeliveryAddress2> <DeliveryAddress3 /> <DeliveryTown></DeliveryTown> <DeliveryCounty /> <DeliveryCountry>244</DeliveryCountry> <DeliveryPhone>1234567</DeliveryPhone> <BillingTitle>Mr</BillingTitle> <BillingFirstName>First</BillingFirstName> <BillingLastName>Name</BillingLastName> <BillingCompanyName>Technology Company</BillingCompanyName> <BillingAddress1>64 Zoo Lane</BillingAddress1> <BillingAddress2 /> <BillingAddress3 /> <BillingTown></BillingTown> <BillingCounty></BillingCounty> <BillingPostcode>postcode</BillingPostcode> <BillingCountry>244</BillingCountry> <BillingPhone>1234567</BillingPhone> <CompanyCode /> <Currency>3</Currency> <DomainID>2</DomainID> <OrderID>1033</OrderID> <OrderDate>2017-02-23T13:59:57.343</OrderDate> <Login>login@company.com</Login> <TotalGross>405.90</TotalGross> <TotalNet>330.00</TotalNet> <TotalTax>75.90</TotalTax> <OrderLines> <OrderLine ItemTypeName="OrderDiscount"> <OrderLineID>87</OrderLineID> <Code>MHA - Fixed Amount off an Order</Code> <Name>MHA - Fixed Amount off an Order</Name> <Quantity>1</Quantity> <UnitPrice>0.000000</UnitPrice> <UnitPriceDiscounted>-20.000000</UnitPriceDiscounted> <UnitDiscount>20.000000</UnitDiscount> <LinePrice>0.00</LinePrice> <LinePriceDiscounted>-20.00</LinePriceDiscounted> <TotalTax>-4.60</TotalTax> <TotalNet>-20.00</TotalNet> <TotalGross>-24.60</TotalGross> </OrderLine> <OrderLine ItemTypeName="DeliveryOption"> <OrderLineID>89</OrderLineID> <Code>ZeusFleet</Code> <Name>Delivery Via Fleet</Name> <Quantity>1</Quantity> <UnitPrice>0.000000</UnitPrice> <UnitPriceDiscounted>0.000000</UnitPriceDiscounted> <UnitDiscount>0.000000</UnitDiscount> <LinePrice>0.00</LinePrice> <LinePriceDiscounted>0.00</LinePriceDiscounted> <TotalTax>0.00</TotalTax> <TotalNet>0.00</TotalNet> <TotalGross>0.00</TotalGross> </OrderLine> <OrderLine ItemTypeName="Product"> <OrderLineID>88</OrderLineID> <Code>BB=CURVE9320-WH</Code> <Name>BlackBerry Curve 9320 White</Name> <Quantity>1</Quantity> <UnitPrice>350.000000</UnitPrice> <UnitPriceDiscounted>350.000000</UnitPriceDiscounted> <UnitDiscount>0.000000</UnitDiscount> <LinePrice>350.00</LinePrice> <LinePriceDiscounted>350.00</LinePriceDiscounted> <TotalTax>80.50</TotalTax> <TotalNet>350.00</TotalNet> <TotalGross>430.50</TotalGross> </OrderLine> </OrderLines> <OrderDiscounts> <OrderDiscount> <Code>MHA - Fixed Amount off an Order</Code> <Name>MHA - Fixed Amount off an Order</Name> <TotalTax>0.0000</TotalTax> <TotalNet>20.0000</TotalNet> <TotalGross>20.0000</TotalGross> <UnitDiscount /> <UnitPriceDiscounted /> <LineDiscount /> <LinePriceDiscounted /> </OrderDiscount> </OrderDiscounts> </Order> </Orders> ENDTEXT * this will do for the top level XMLTOCURSOR(m.OriginalFile, "Orders") BROWSE * to fetch the orders details, we'll have to transform into another XML document * this will fetch also, as columns, the order ID that applies to the detail, and * the Item Type Number (whatever that may be) LOCAL GetOrderDetailsStylesheet AS String TEXT TO m.GetOrderDetailsStylesheet NOSHOW <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" exclude-result-prefixes="xsd xsi"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:element name="OrderLines"> <xsl:apply-templates select="Orders/Order"/> </xsl:element> </xsl:template> <xsl:template match="Order"> <xsl:variable name="orderID" select="OrderID"/> <xsl:for-each select="OrderLines/OrderLine"> <xsl:element name="OrderLine"> <xsl:element name="OrderID"> <xsl:value-of select="$orderID"/> </xsl:element> <xsl:element name="ItemTypeName"> <xsl:value-of select="@ItemTypeName"/> </xsl:element> <xsl:copy-of select="*"/> </xsl:element> </xsl:for-each> </xsl:template> </xsl:stylesheet> ENDTEXT LOCAL XML AS MSXML2.DOMDocument60 LOCAL XSLT AS MSXML2.DOMDocument60 m.XML = CREATEOBJECT("MSXML2.DOMDocument.6.0") m.XML.async = .F. m.XML.loadXML(m.OriginalFile) m.XSLT = CREATEOBJECT("MSXML2.DOMDocument.6.0") m.XSLT.async = .F. m.XSLT.loadXML(m.GetOrderDetailsStylesheet) XMLTOCURSOR(m.XML.transformNode(m.XSLT), "OrderLines") SELECT OrderLines BROWSE