ApiExamples.ExNode.EnumerateChildNodes C# (CSharp) Метод

EnumerateChildNodes() приватный Метод

private EnumerateChildNodes ( ) : void
Результат void
        public void EnumerateChildNodes()
        {
            Document doc = new Document();
            //ExStart
            //ExFor:Node
            //ExFor:CompositeNode
            //ExFor:CompositeNode.GetChild
            //ExSummary:Shows how to extract a specific child node from a CompositeNode by using the GetChild method and passing the NodeType and index.
            Paragraph paragraph = (Paragraph)doc.GetChild(NodeType.Paragraph, 0, true);
            //ExEnd

            //ExStart
            //ExFor:CompositeNode.ChildNodes
            //ExFor:CompositeNode.GetEnumerator
            //ExId:ChildNodesForEach
            //ExSummary:Shows how to enumerate immediate children of a CompositeNode using the enumerator provided by the ChildNodes collection.
            NodeCollection children = paragraph.ChildNodes;
            foreach (Node child in children)
            {
                // Paragraph may contain children of various types such as runs, shapes and so on.
                if (child.NodeType.Equals(NodeType.Run))
                {
                    // Say we found the node that we want, do something useful.
                    Run run = (Run)child;
                    Console.WriteLine(run.Text);
                }
            }
            //ExEnd
        }