Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question on processing XML file
Message
 
 
To
01/12/2003 14:21:06
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
00854652
Message ID:
00854849
Views:
30
Hi Aleksey,

Thank you very much for the sample code.

>>I agree, and I actually did just that. I created xmlAdapter object, loaded an xml file into it and was checking different properties. But I didn't find anything useful to me. And I am sure it was just me not know my way around it. I will check out your message.
>>
>
>Hi Dmitry,
>
>XMLAdapter requires a schema. Either you have to include XML schema or external reference to the schema into your XML document or you can populate XMLAdapter.Tables collection manually.
>
>
>CLOSE DATABASES all
>clear
>
>TEXT TO cXml NOSHOW
><?xml version="1.0"?>
><service>
>   <add key="key1" value="value1" />
>   <add key="key2" value="value2" />
></service>
>ENDTEXT
>
>LOCAL oXA as XMLAdapter, oXT as XMLTable, oXF as XMLField
>
>oXA=CREATEOBJECT("XMLAdapter")
>oXA.XMLSchemaLocation=""
>oXA.XMLName=STRCONV("service",5)
>oXA.LoadXML(cXML,.F.)
>
>
>oXT=CreateXmlTable("add","addTable")
>oXA.Tables.Add(oXT,oXT.XMLName)
>AddXmlField(oXT,"key",.T.,"key","C",5)
>AddXmlField(oXT,"value",.T.,"value","C",10)
>
>oXT.ToCursor()
>ListTable(oXT)
>
>RETURN
>
>
>
>FUNCTION ListTable(oXT)
>SELECT (oXT.Alias)
>?ALIAS()
>LIST
>ENDFUNC
>
>FUNCTION CreateXmlTable(cXMLName,cAlias)
>	oXT=CREATEOBJECT("XMLTable")
>	oXT.XMLName=STRCONV(cXMLName,5)
>	oXT.Alias=cAlias
>	RETURN oXT
>ENDFUNC
>
>FUNCTION AddXmlField(oXT,cXMLName,lAttribute,cAlias,cDataType,nMaxLength)
>	oXF=CREATEOBJECT("XMLField")
>	oXF.XMLName=STRCONV(cXMLName,5)
>	oXF.IsAttribute= lAttribute
>	oXF.Alias=cAlias
>	oXF.DataType=cDataType
>	oXF.MaxLength=nMaxLength
>	oXT.Fields.Add(oXF,oXF.XMLName)
>	RETURN oXF	
>ENDFUNC
>
>
>Thanks,
>Aleksey.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform