Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Xmltocursor xml parse error node
Message
De
06/08/2008 10:01:29
 
 
À
17/07/2008 07:22:35
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:
01336860
Vues:
21
Thanks for all your help. It is always greatly appreciated. For now I'm using filetostr and strtofile to bring the file file in, make changes, and then save it back.

If I run into a probem with this, I will certainly refer back to your code.

Thanks again.
Regards,
Deb


>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.
>>
>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform