使用XmlNode获得仅当前节点的InnerText [英] Obtaining InnerText of just the current node with XmlNode

查看:143
本文介绍了使用XmlNode获得仅当前节点的InnerText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XMLNode,其主体如下所示:(通过OpenCalais)

I have an XMLNode whose body looks like this: (via OpenCalais)

    <SocialTag importance="2">Signal processing
<originalValue>Signal processing</originalValue>
</SocialTag>

当我在其上调用 XMLMNode.InnerText 时,我回来了:

When I call XMLMNode.InnerText on it, I get back:

SignalprocessingSignalprocessing

但是,我只希望标签本身提供InnerText,而不希望子原始值节点的InnerText。

However, I only want the InnerText from the tag itself, and not the InnerText of the child 'original value' node.

何时我叫 XMLNode.Value ,它返回空值。

When I call XMLNode.Value, it returns null.

如何仅获取该节点的InnerText,而没有串联其他子节点的所有InnerText?

How can I get just the InnerText of this node, without concatenating all of the InnerTexts of other child nodes?

推荐答案

XmlNode 实际上是另一个 XmlNode 类型为text。这应该可行:

The text inside the XmlNode is actually another XmlNode of type text. This should work:

socialTagNode.ChildNodes[0].Value

这篇关于使用XmlNode获得仅当前节点的InnerText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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