Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML file to Cursor
Message
From
21/11/2006 21:32:50
 
 
To
21/11/2006 03:58:38
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
01170611
Message ID:
01171619
Views:
14
>>
>> thanks again, i already send my xsd to your email because i dont know how to attach and open my xsd file.
>>
>
>Hi Ryan,
>
>XMLAdapter is not able to load this schema because the schema declares different element types with the same name - "row". But if I modify the schema, load it and then do some tweaking for XMLTable objects, data can be loaded.
>
>Modify the XSD schema, change the first occurrence of
element name="row"
to
element name="row1"
, the second accordance to
element name="row2"
, etc. Save the schema as Good_Receipt_PO_Modified.xsd.
>
>The following code should load data:
>
>CLEAR
>CLOSE TABLES ALL
>
>LOCAL oXA as XMLAdapter, oXT as XMLTable
>
>oXA=CREATEOBJECT("XMLAdapter")
>oXA.RespectNesting= .T.
>oXA.XMLSchemaLocation="Good_Receipt_PO_Modified.xsd"
>?oXA.LoadXML("Good_Receipt_PO.xml",.T.)
>?oXA.Tables.Count
>oXA.XMLNameIsXPath= .T.
>oXA.XMLName = STRCONV("parent::node()",5)
>
>
>FixXMLName(oXA,"row1")
>FixXMLName(oXA,"row2")
>FixXMLName(oXA,"row3")
>FixXMLName(oXA,"row4")
>FixXMLName(oXA,"row5")
>FixXMLName(oXA,"row6")
>FixXMLName(oXA,"row7")
>
>FOR each oXT IN oXA.Tables
>	IF oXT.Fields.Count >0
>		oXT.ToCursor()
>		SELECT (oXT.Alias )
>		IF RECCOUNT()=0
>			USE
>		ENDIF
>	ENDIF
>NEXT
>
>
>
>FUNCTION FixXMLName(oXA as XMLAdapter,cName)
>	cName=STRCONV(cName,5)
>
>	LOCAL oXT as XMLTable
>	oXT=oXA.Tables(cName)
>	oXT1 = oXT.NestedInto
>	oXA.Tables.Remove(cName)
>	
>	cName=STRCONV("row",5)
>	
>	DO WHILE NOT ISNULL(oXT1)
>		cName = oXT1.XMLName + STRCONV("/",5)+cName
>		oXT1 = oXT1.NestedInto
>	ENDDO
>	
>	oXT.XMLNameIsXPath = .T.
>	oXT.XMLName = cName
>	oXA.Tables.Add(oXT,oXT.XMLName)
>return
>
>
>Thanks,
>Aleksey.

Hi aleksey,

I just noticed it now, the docdate and docduedate became "Memo" instead of "20061113" and the other fields with text value became "Memo" in the cursor? is it posible retain their original value?

Thanks,
ryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform