Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question on processing XML file
Message
From
01/12/2003 14:21:06
 
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
00854652
Message ID:
00854784
Views:
39
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform