Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Make XMLTOCURSOR() to ignore schema
Message
De
09/03/2016 12:01:02
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01632742
Message ID:
01632754
Vues:
43
>I want to load XML file into a cursor. Here is an example:
>
>create cursor c_cursor (name c(20), email_addr c(100), account c(50))
>nRecCount = XMLTOCURSOR( "emaillist.xml", "c_cursor", 512+8192)
>
>
>The problem is that the emaillist.xml points to an xsd file emaillist.xsd and I want it to be ignored. Because the emaillist.xsd has no reference of the element "account".
>Can I change the parameter used with XMLTOCURSOR() from 512+8192 so some other value to make it ignore the XSD?
>
>

I'll assume that name, email_addr and account are the elements that you need to read from the XML file, and that they are siblings (that is, they share the same parent).
CREATE CURSOR c_cursor (name c(20), email_addr c(100), account c(50))

LOCAL loXML AS MSXML2.DOMDocument60

m.loXML = CREATEOBJECT("MSXML2.DOMDocument.6.0")

m.loXML.Async = .F.
m.loXML.Load(GETFILE("xml"))

LOCAL loRows AS MSXML2.IXMLDOMNodeList

m.loRows = m.loXML.selectNodes("//*[local-name() = 'email_addr']/parent::node()")

LOCAL loRow AS MSXML2.IXMLDOMNode

FOR EACH m.loRow IN m.loRows
	INSERT INTO c_cursor (name, email_addr, account) ;
		VALUES (m.loRow.selectNodes("name").item(0).text, m.loRow.selectNodes("email_addr").item(0).text, m.loRow.selectNodes("account").item(0).text)
ENDFOR

m.loXML = .NULL.
RELEASE m.loXML
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform