Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XMLField question
Message
From
29/09/2006 14:39:31
 
 
To
28/09/2006 18:13:38
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
01158009
Message ID:
01158247
Views:
38
This message has been marked as the solution to the initial question of the thread.
CLEAR 
CLOSE DATABASES all

TEXT TO cXML1 NOSHOW
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<Total>
     <Line type="Subtotal" name="Subtotal">229.99</Line> 
     <Line type="Coupon" name="Coupon discount (fallshow)">-23.00</Line> 
     <Line type="Subtotal" name="Subtotal">206.99</Line> 
     <Line type="Shipping" name="Shipping">29.14</Line> 
     <Line type="Tax" name="Tax">0.00</Line> 
     <Line type="Total" name="Total">236.13</Line> 
</Total>
ENDTEXT

oTable = SetupXMLTable( "Line", "Line")
AddXMLField( oTable, "self::node()", "line", "C",  40) 
AddXMLField( oTable, "@name", "_name", "C",  40) 
AddXMLField( oTable, "@type", "_type", "C",  10)

LOCAL oXA as XMLAdapter 
oXA = CREATEOBJECT("XMLAdapter")

oXA.LoadXML(cXML1)
oXA.Tables.Add(oTable, oTable.XMLName) 

oTable.ToCursor()
SELECT Line
LIST

Procedure SetupXMLTable( lcName, lcAlias)
	Local oTable
	oTable = Createobject("XMLTable")
	* all XMLName properties must be Unicode
	oTable.XMLName = Strconv(lcName, 5)
	oTable.XMLNameIsXpath = .T.
	* the cursor's alias
	oTable.Alias = lcAlias
	If Used(lcAlias)
		Use In (lcAlias)
	Endif
	Return oTable
Endproc

Procedure AddXMLField( oTable, lcXMLName, lcAlias, lcDataType, lnMaxLength, lnFractionDigits)
	Local oField
	oField = Createobject("XMLField")

	oField.XMLName = Strconv( lcXMLName, 5)
	oField.XMLNameIsXpath = .T.
	oField.Alias = Evl( lcAlias, lcXMLName)
	oField.DataType = lcDataType
	oField.MaxLength = lnMaxLength
	If Not Empty( lnFractionDigits)
		oField.FractionDigits =  lnFractionDigits
	Endif

	oTable.Fields.Add(oField, oField.XMLName)
	Return oTable
Endproc
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform