使用 MSXML 在 Xml 中遍历节点

发布于 2024-07-30 17:24:37 字数 449 浏览 5 评论 0原文

我正在尝试遍历节点属性..在下面的 xml 中,我需要在属性值“1”或“2”匹配中附加一个新节点..如何使用 MSXML 属性为此编写代码..帮助我 即通过属性浏览 xml ...

<data>
    <menu id="**1**">
        <existes>01</existes>
    </menu>
    <menu id="**2**">
       <existes>1</existes>
       <existes>2</existes>
   </menu>
    <  menu id="**3**">
    <existes>2</existes>
   </menu>
</data>

i am trying to traverse a node attributes ..in below xml ,i need to attach a new node in attribute value '1'or'2'matched.. how can write a code for that using MSXML property..help me
i.e browse xml through attribute ...

<data>
    <menu id="**1**">
        <existes>01</existes>
    </menu>
    <menu id="**2**">
       <existes>1</existes>
       <existes>2</existes>
   </menu>
    <  menu id="**3**">
    <existes>2</existes>
   </menu>
</data>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗲 2024-08-06 17:24:37

因此,假设您知道如何遍历文档中的节点。
MSXML 公开用于遍历 IXMLDOMNode - 您需要将其转换为 IXMLDOMElement(在 C++ 中使用 C# 中的 QueryInterface 或 VB 只需转换为预期接口)。
IXMLDOMElement - 具有可枚举属性“属性” - 因此您可以迭代元素的所有属性。

So assuming you know how to traverse nodes over document.
MSXML exposes for traverse IXMLDOMNode - you need cast it to IXMLDOMElement ( in c++ use QueryInterface in C# or VB just cast to expected interface).
IXMLDOMElement - has enumerable property 'attributes' - so you can iterate all attrs of element.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文