首页 > 解决方案 > C# XmlNode.ChildNodes 断线计为节点

问题描述

我有这些 xml

<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/">
    <atom:id>urn:uuid:00000000-0000-0000-0000-00000000000</atom:id>
    <atom:title>RenamedDocument</atom:title>
    <atom:updated>2012-07-13T06:14:05Z</atom:updated>
    <cmisra:object xmlns:ns3="http://docs.oasis-open.org/ns/cmis/messaging/200908/">
        <cmis:properties>
        <cmis:propertyString propertyDefinitionId="cmis:name">
                <cmis:value>RenamedDocument</cmis:value>
            </cmis:propertyString>
            <cmis:propertyString propertyDefinitionId="cmisma:[OSTERONE]Test">
                <cmis:value>[NULL]</cmis:value>
            </cmis:propertyString>
        </cmis:properties>
    </cmisra:object>
</atom:entry>

我想拥有每个孩子,cmis:property所以我这样做

XmlNodeList list = rawData.GetElementsByTagName("cmis:properties")[0].ChildNodes; 但我有 5 个孩子。似乎每个 \n 都被视为一个节点。

我怎样才能压制这些断线只有“真正的孩子”?

标签: c#

解决方案


感谢juharr,我找到了一种方法NodeType。只需要使用NodeType != NodeType.Whitespace. 谢谢 !


推荐阅读