Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML file to Cursor
Message
From
20/11/2006 02:03:18
 
 
To
20/11/2006 01:11:23
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
01170611
Message ID:
01171103
Views:
13
>>
>> i have a XSD schema for this, is it posibble to import directly to cursors or tables(dbf)?.
>>
>
>There is an example in Message #779647.

hi,

Thanks for the solution but I am not smart enough to understand the example.
I attached my XML to your example and i comment the original, can you do it for me as a solution to my problem?

Thanks,
Ryan
CLOSE DATABASES all
clear

TEXT TO cXml NOSHOW
*!*	<?xml version="1.0" encoding="utf-8" ?> 
*!*	<root>
*!*		<Header Sender='CompanyA' Recipient='CompanyB'>
*!*			<Detail Trailer_ID='3545452355454234' Lorry_ID='1523445532'/>
*!*			<Detail Trailer_ID='4444442355454234' Lorry_ID='5555545532'/>
*!*		</Header>	
*!*	</root>	
<?xml version="1.0" encoding="UTF-16" ?> 
- <BOM>
- <BO>
- <AdmInfo>
  <Object>20</Object> 
  <Version>2</Version> 
  </AdmInfo>
- <Documents>
- <row>
  <DocNum>5</DocNum> 
  <U_SORef>1</U_SORef> 
  </row>
  </Documents>
- <Document_Lines>
- <row>
  <LineNum>0</LineNum> 
  <ItemCode>A00001</ItemCode> 
  <ItemDescription>IBM Inforprint 1312</ItemDescription> 
  <Quantity>10.000000</Quantity> 
  </row>
  </Document_Lines>
  </BO>
  </BOM>
ENDTEXT


TEXT TO cXmlSchema NOSHOW
<?xml version="1.0" encoding="utf-8" ?> 
<xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
        attributeFormDefault="qualified" elementFormDefault="qualified">
	<xs:element name="root" msdata:IsDataSet="true">
		<xs:complexType>
			<xs:choice maxOccurs="unbounded">
				<xs:element name="Header">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Detail"  minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:attribute name="Trailer_ID" form="unqualified">
										<xs:simpleType>
											<xs:restriction base="xs:string">
												<xs:maxLength value="20" /> 
											</xs:restriction>
										</xs:simpleType>
									</xs:attribute>
									<xs:attribute name="Lorry_ID" form="unqualified">
										<xs:simpleType>
											<xs:restriction base="xs:string">
												<xs:maxLength value="10" /> 
											</xs:restriction>
										</xs:simpleType>
									</xs:attribute>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
						<xs:attribute name="Sender" form="unqualified">
							<xs:simpleType>
								<xs:restriction base="xs:string">
									<xs:maxLength value="10" /> 
								</xs:restriction>
							</xs:simpleType>
						</xs:attribute>
						<xs:attribute name="Recipient" form="unqualified">
							<xs:simpleType>
								<xs:restriction base="xs:string">
									<xs:maxLength value="10" /> 
								</xs:restriction>
							</xs:simpleType>
						</xs:attribute>
					</xs:complexType>
				</xs:element>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>
ENDTEXT

STRTOFILE(cXmlSchema,"NewSchema.xsd")

LOCAL oXA as XMLAdapter, oXT as XMLTable

oXA=CREATEOBJECT("XMLAdapter")
oXA.XMLSchemaLocation="NewSchema.xsd"
oXA.LoadXML(cXml)

FOR EACH oXT IN oXA.Tables
	?oXT.ToCursor()
	SELECT (oXT.Alias)
	?ALIAS()
	LIST
NEXT

return
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform