Visual FoxPro 9 中的 XMLAdapter 类
我在 Vista 上以管理员帐户使用 Visual FoxPro 9。我正在尝试执行以下程序:
cFile = "c:\XMLAdapter\CustomerXML.xml"
adapter = CREATEOBJECT("XMLAdapter")
adapter.LoadXML(cFile,.T.)
adapter.Tables(1).ToCursor()
我已从《代码杂志》( 使用 XMLAdapter 将 XML 转换为 VFP 游标)。当我执行它时,出现以下错误:索引或表达式与集合的现有成员不匹配。它在程序的最后一行崩溃。
在同一篇文章中,还有这个程序:
cFile = "c:\XMLAdapter\EmployeeXML.xml"
OPEN DATABASE (_samples+"\northwind\northwind")
SELECT employeeid, lastname ;
FROM Employees;
INTO CURSOR curEmployees
adapter = CREATEOBJECT("XMLAdapter")
adapter.AddTableSchema("curEmployees")
adapter.ToXML(cFile,,.T.)
这工作完美。
如果有人能帮助我理解为什么第一个程序崩溃了,我真的很感激?
谢谢
I’m using Visual FoxPro 9 on Vista in the administrator account. I’m trying to execute the following program:
cFile = "c:\XMLAdapter\CustomerXML.xml"
adapter = CREATEOBJECT("XMLAdapter")
adapter.LoadXML(cFile,.T.)
adapter.Tables(1).ToCursor()
I’ve copied this program verbatim (except for changing the path of the XML file) from an article in Code Magazine ( Converting XML to VFP Cursors Using the XMLAdapter ). When I execute it, I get the following error: Index or expression does not match an existing member of the collection. It is crashing on the last line of the program.
In the same article, there is also this program:
cFile = "c:\XMLAdapter\EmployeeXML.xml"
OPEN DATABASE (_samples+"\northwind\northwind")
SELECT employeeid, lastname ;
FROM Employees;
INTO CURSOR curEmployees
adapter = CREATEOBJECT("XMLAdapter")
adapter.AddTableSchema("curEmployees")
adapter.ToXML(cFile,,.T.)
This works perfectly.
I’d really appreciate it, if anyone could help me understand why the first program is crashing?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XMLAdapter 类对于它所接受的 XML 类型非常挑剔。我在文章中看不到代表 c:\XMLAdapter\CustomerXML.xml 的实际文件的链接,是否有一个我没有见过的文件,或者这只是用于演示目的?如果没有,我希望您创建自己的有效 XML 文件:分析第二个代码示例生成的文件应该足以创建 XMLAdapter 可接受的内容。
如果您需要 XMLAdapter 的文档和示例,请访问 Google 图书搜索上的顶部链接 会有帮助
The XMLAdapter class is fussy about the types of XML it will accept. I can't see a link to an actual file that represents c:\XMLAdapter\CustomerXML.xml in the article, is there one I haven't seen or is this just used for demonstration purposes? If there isn't one, I expect you created your own valid XML file: analyzing the file produced by your second code example should be enough to create something acceptable to the XMLAdapter.
If you want documentation and examples of the XMLAdapter, the top links on a Google books search will help