Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parsing XML with DOM
Message
 
À
20/11/2004 00:05:35
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Versions des environnements
Visual FoxPro:
VFP 7
Divers
Thread ID:
00962465
Message ID:
00963172
Vues:
9
Hi Don,

Your XML is invalid because have not root element.
Exapmples:

XML & DTD
don2.xml
<?xml version="1.0" encoding="windows-1252" standalone="yes"?>
<!DOCTYPE DOCUMENT SYSTEM "don2.dtd">
<root>
 <schedule time="1" display="45" program="xx76578" />
 <data>
  <data1>xxx</data1>
  <data2>XXX</data2>
 </data>
</root>
don2.dtd
<?xml version="1.0" encoding="windows-1252"?>
<!ELEMENT root (schedule,data)>

<!ELEMENT schedule (#PCDATA)>
<!ATTLIST schedule program  CDATA #REQUIRED
                   time  CDATA #REQUIRED
                   display CDATA #REQUIRED >

<!ELEMENT data (#PCDATA)>
<!ELEMENT data (data1,data2)>

<!ELEMENT data1 (#PCDATA)>

<!ELEMENT data2 (#PCDATA)>
XML & XSD
don.xml
<?xml version="1.0" encoding="windows-1252" standalone="yes"?>
<root xmlns="urn:don" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="urn:don don.xsd">

 <schedule time="1" display="45" program="xx76578" />
 <data>
  <data1>xxx</data1>
  <data2>XXX</data2>
 </data>

</root>
don.xsd
<?xml version="1.0" encoding="windows-1252" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:don"
    xmlns="urn:don" elementFormDefault="qualified">

 <xs:complexType name="dataelement">
 </xs:complexType>

 <xs:complexType name="dataelements">
  <xs:sequence>
   <xs:element name="data1" type="dataelement" minOccurs="1" maxOccurs="1" />
   <xs:element name="data2" type="dataelement" minOccurs="1" maxOccurs="1" />
  </xs:sequence>
 </xs:complexType>

 <xs:complexType name="schemaelement">
  <xs:attribute name="program" type="xs:string" use="required" />
  <xs:attribute name="type" type="xs:int" use="required" />
  <xs:attribute name="time" type="xs:float" use="required" />
 </xs:complexType>

 <xs:complexType name="root">
  <xs:sequence>
   <xs:element name="scheme" type="schemaelement" minOccurs="1" maxOccurs="1" />
   <xs:element name="data" type="dataelements" minOccurs="1" maxOccurs="1" />
  </xs:sequence>
 </xs:complexType>

 </xs:element>
</xs:schema>
MartinJ

>Well I'll be @!#*. You are right. I've been running in circles trying to figure out how to write schemas and dtd's and never thought to try the xmltocursor on this piece of data. The sample of course is only part of a much more complex file that has data in mixed forms like that shown (mixed between <>) and also other parts where the data is separated into discrete elements like:
>
>
><schedule time=1 display=45 program=xx76578 />
><data>
><data1>xxx</data1>
><data2>XXX</data2>
></data>
>
>
>Can you give me some help on how to write a schema to deal with this? I'd prefer to do the whole job in VFP if I can.
>
>Thanks for your tip.
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform