Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

C# XmlNode.ChildNodes breakline count as node

I have these 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>

and I would like to have every children of cmis:property so I do

XmlNodeList list = rawData.GetElementsByTagName("cmis:properties")[0].ChildNodes; but I have 5 children. It's appear that every is count as a node.

How can I suppress these breakline to have only the "real children" ?

question from:https://stackoverflow.com/questions/66047206/c-sharp-xmlnode-childnodes-breakline-count-as-node

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Thanks to juharr, I found a way with NodeType. Just have to make an if condition with NodeType != NodeType.Whitespace. Thanks you !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...