如何使用VBA解析XML [英] How to parse XML using vba

查看:297
本文介绍了如何使用VBA解析XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VBA中工作,想解析一个字符串,例如

I work in VBA, and want to parse a string eg

<PointN xsi:type='typens:PointN' 
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
    <X>24.365</X>
    <Y>78.63</Y>
</PointN>

并获得X& Y值分成两个单独的整数变量.

and get the X & Y values into two separate integer variables.

在XML方面,我是一个新手,因为我从事的领域很有限,所以我一直停留在VB6和VBA中.

I'm a newbie when it comes to XML, since I'm stuck in VB6 and VBA, because of the field I work in.

我该怎么做?

推荐答案

这是一个复杂的问题,但是似乎最直接的途径是通过MSXML2.DOMDocument加载XML文档或XML字符串,这将然后允许您访问XML节点.

This is a bit of a complicated question, but it seems like the most direct route would be to load the XML document or XML string via MSXML2.DOMDocument which will then allow you to access the XML nodes.

您可以在以下站点上找到有关MSXML2.DOMDocument的更多信息:

You can find more on MSXML2.DOMDocument at the following sites:

  • Manipulating XML files with Excel VBA & Xpath
  • MSXML - http://msdn.microsoft.com/en-us/library/ms763742(VS.85).aspx
  • An Overview of MSXML 4.0

这篇关于如何使用VBA解析XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆