gpt4 book ai didi

xml - 创建自定义 XML 映射

转载 作者:数据小太阳 更新时间:2023-10-29 02:34:23 25 4
gpt4 key购买 nike

我正在尝试使用 Excel VBA 创建自定义 XML map 。我的 XML 文件是 BookData.xml:

<?xml version='1.0'?>
<BookInfo>
<Book>
<ISBN>989-0-487-04641-2</ISBN>
<Title>My World</Title>
<Author>Nancy Davolio</Author>
<Quantity>121</Quantity>
</Book>
<Book>
<ISBN>981-0-776-05541-0</ISBN>
<Title>Get Connected</Title>
<Author>Janet Leverling</Author>
<Quantity>435</Quantity>
</Book>
<Book>
<ISBN>999-1-543-02345-2</ISBN>
<Title>Honesty</Title>
<Author>Robert Fuller</Author>
<Quantity>315</Quantity>
</Book>
</BookInfo>

我在 Excel 2013 中的 VBA 代码是:

Sub Create_XSD()
Dim StrMyXml As String, MyMap As XmlMap
Dim StrMySchema As String
StrMyXml = "< BookInfo >"
StrMyXml = StrMyXml & "<Book>"
StrMyXml = StrMyXml & "<ISBN>Text</ISBN>"
StrMyXml = StrMyXml & "<Title>Text</Title>"
StrMyXml = StrMyXml & "<Author>Text</Author>"
StrMyXml = StrMyXml & "<Quantity>999</Quantity>"
StrMyXml = StrMyXml & "</Book>"
StrMyXml = StrMyXml & "<Book></Book>"
StrMyXml = StrMyXml & "</ BookInfo >"

' Turn off async loading.
Application.DisplayAlerts = False
' Add the string to the XmlMaps collection.
Set MyMap = ThisWorkbook.XmlMaps.Add(StrMyXml)
Application.DisplayAlerts = True

' Create an empty file and output the schema.
StrMySchema = ThisWorkbook.XmlMaps(1).Schemas(1).XML
Open "C:\Documents\MySchema.xsd" For Output As #1
Print #1, StrMySchema
Close #1
End Sub

返回错误:

Error

在线:

   Set MyMap = ThisWorkbook.XmlMaps.Add(StrMyXml)

我试图了解如何使用 VBA 构建自定义 XML 映射的逻辑,以便我可以在另一个(更复杂的)XML 文件上使用它。我关注的代码是 here .

那么,如何解决这个错误呢?

最佳答案

删除"</ BookInfo >"中的空格

关于xml - 创建自定义 XML 映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33550844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com