Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor to XML not picking up lines
Message
From
09/05/2017 12:31:43
 
 
To
09/05/2017 11:07:05
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008 R2
Network:
Windows Server 2008 R2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01650938
Message ID:
01650966
Views:
71
Ok, I see you solved the attribute via xslt ( great !)
Anyway, I'll leave here another simple solution if no attribute is needed for other cases:
Close Tables All
clear
* no error detection etc etc..

cXml = getxml()
oXML = Createobject("msxml2.domdocument.6.0")
oXML.LoadXML(m.cXml)

orders = m.oXML.selectNodes('/Orders').item(0).childNodes

For N = 0 To orders.Length-1

	oNode = orders.Item(m.n)

	xmltocursor('<Orders>'+m.oNode.xml+'</Orders>','Order')
	Browse

	xmltocursor2(m.oNode,'OrderDiscounts','OrderDiscounts')
	Browse

	xmltocursor2(m.oNode,'OrderLines','orderLines')
	Browse

Endfor


*----------------------------------------------------
Function xmltocursor2( oXML , xpath, ccursorname )
*----------------------------------------------------
Xmltocursor( oXML.selectNodes(m.xpath).Item(0).XML , m.ccursorname )


*-----------------------------
Function getxml()
*-----------------------------

TEXT TO cXml 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>ORDER 1</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 #1</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 Order #1</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 #1</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>

	<Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
		<DeliveryCompanyName />
		<DeliveryTitle>ORDER 2</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 #2</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 #2</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

Return cXml
@nfoxdev
github.com/nfoxdev
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform