Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Xmltocursor xml parse error node
Message
 
 
À
16/07/2008 12:56:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 2000 SP4
Network:
Windows NT
Database:
Visual FoxPro
Divers
Thread ID:
01330640
Message ID:
01331910
Vues:
18
I would rather use XmlDom (MSXML). See sample code below
lcXmlFile = FULLPATH("...")

loXmlDoc = CreateObject("Msxml2.DOMDocument.3.0")		&& MSXML 3.0, used by Xmltocursor()
*loXmlDoc = CreateObject("Msxml2.DOMDocument.4.0")		&& MSXML 4.0, used by XmlAdaptor

* Turn some switches off
loXmlDoc.validateOnParse = .F.
loXmlDoc.async  = .F.
loXmlDoc.resolveExternals  = .F.
* 	and On
loXmlDom.preserveWhiteSpace = .T.

* Load the xml document
= loXmlDoc.Load(lcXmlFile)

* Check for errors
If loXmlDoc.parseError.errorCode <> 0
   ?loXmlDoc.parseError.reason
   RETURN .F.
ENDIF
   
* Set SelectionLanguage to XPath    
= loXmlDoc.SetProperty("SelectionLanguage", "XPath")
* Set namespace. 'ns' is an arbitrary name
= loXmlDoc.SetProperty("SelectionNamespaces", "xmlns:ns='" + loXmlDoc.namespaces(0)+"'")

* Read and set some items
? ChangeItem(loXmlDoc, "address", "Some New Address")
? ChangeItem(loXmlDoc, "contact", "New Name")

* Save XML back
loXmlDoc.Save(lcXmlFile)

loXmlDoc = NULL
RETURN

FUNCTION ChangeItem(toXmlDom, tcAttributeName, tvNewValue)
LOCAL loItem, llOK
? "Item:", tcAttributeName
loItem = toXmlDom.selectSingleNode("//ns:field[@name='" + tcAttributeName + "']")
llOK = NOT ISNULL(loItem)
IF llOK 
	? "Before:", loItem.nodeTypedValue
	loItem.nodeTypedValue = tvNewValue
	? "After:", loItem.nodeTypedValue
	loItem = NULL
ENDIF

RETURN llOK
ENDFUNC
>I decided to bring the data in my xfdf file into my app using lcstring = filetostr(nys.xfdf)
>So now lcstring has all the data.
>
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform