XML解析为excel

时间:2013-07-10 11:21:06

标签: xml excel excel-vba excel-2013 vba

我已经完成了大约20个尝试将xml解析为excel的示例,似乎没有一个适用于我的源代码。这里的一个大问题是我不知道如何在excel VBA中解析xml。

以下是我的问题:

1)我是否有任何在线资源可以用来理解你们推荐的excel中使用的MSXML参考库? 2)我试图解析的xml是否存在格式错误? (参见下面的例子xml)

错误消息通常似乎有两个主题..示例使用的是未在MSXML v6中定义的变量,或者它打开xml但从未找到文档元素。

* 更新:对不起,我应该说我正在尝试获取消息href,主题标题,发布日期和变量Kudos

<response status="success">
<node_message_context type="node_message_context">
<message type="message" href="/messages/id/25704">
<id type="int">25704</id>
<read_only type="boolean">false</read_only>
<message_rating type="float">0.0</message_rating>
<last_edit_author type="user" href="/users/id/1094">
<login type="string">AllenSmith</login>
</last_edit_author>
<kudos>
<count type="int">1</count>
</kudos>
<last_edit_time type="date_time">2013-06-26T13:23:44+00:00</last_edit_time>
<post_time type="date_time">2013-06-26T13:23:44+00:00</post_time>
<board type="board" href="/boards/id/DesktopAPI"/>
<subject type="string">
Re: SKYPE4COM MessageSta​tus received event doesn't fire all the times (skype window has or not focu
</subject>
<deleted type="boolean">false</deleted>
<author type="user" href="/users/id/1094">
<login type="string">AllenSmith</login>
</author>
<thread type="thread" href="/threads/id/25696"/>
<root type="message" href="/messages/id/25696"/>
<board_id type="int">1331</board_id>
<parent type="message" href="/messages/id/25696"/>
<teaser type="string"/>
<views>
<count type="int">43</count>
</views>
</message>
<message type="message" href="/messages/id/25690">
<id type="int">25690</id>
<read_only type="boolean">false</read_only>
<message_rating type="float">0.0</message_rating>
<last_edit_author type="user" href="/users/id/1094">
<login type="string">AllenSmith</login>
</last_edit_author>
<kudos>
<count type="int">0</count>
</kudos>
<last_edit_time type="date_time">2013-06-25T13:38:17+00:00</last_edit_time>
<post_time type="date_time">2013-06-25T13:38:17+00:00</post_time>
<board type="board" href="/boards/id/SkypeKitAPI"/>
<subject type="string">Re: Connection to the runtime was refused</subject>
<deleted type="boolean">false</deleted>
<author type="user" href="/users/id/1094">
<login type="string">AllenSmith</login>
</author>
<thread type="thread" href="/threads/id/23414"/>
<root type="message" href="/messages/id/23414"/>
<board_id type="int">6977</board_id>
<parent type="message" href="/messages/id/23414"/>
<teaser type="string"/>
<views>
<count type="int">64</count>
</views>
</message>

1 个答案:

答案 0 :(得分:0)

xml存在错误。我建议通过http://www.xmlvalidation.com/之类的验证服务来运行它,它会告诉你需要改变什么才能使这个形成良好的xml。