Пример #1
0
 public static void NodesAfterSelfBeforeAndAfter()
 {
     XText aText = new XText("a"), bText = new XText("b");
     XElement a = new XElement("A", aText, bText);
     IEnumerable<XNode> nodes = aText.NodesAfterSelf();
     Assert.Equal(1, nodes.Count());
     bText.Remove();
     Assert.Equal(0, nodes.Count());
 }
Пример #2
0
        public static void NodesAfterSelfBeforeAndAfter()
        {
            XText               aText = new XText("a"), bText = new XText("b");
            XElement            a     = new XElement("A", aText, bText);
            IEnumerable <XNode> nodes = aText.NodesAfterSelf();

            Assert.Equal(1, nodes.Count());
            bText.Remove();
            Assert.Equal(0, nodes.Count());
        }
Пример #3
0
        private static string CollectText(XText n)
        {
            string s = n.Value;

            if (n.GetParent() != null)
            {
                foreach (XNode node in n.NodesAfterSelf())
                {
                    XText?t = node as XText;
                    if (t == null)
                    {
                        break;
                    }
                    s += t.Value;
                }
            }
            return(s);
        }
        public static List <XText> GetFollowSiblingXTexts(this XText xtxt)
        {
            List <XText> xtxts = null;

            if (xtxt != null)
            {
                var texts = xtxt.NodesAfterSelf().Where(x => x is XText).ToList();
                if (texts != null && texts.Count > 0)
                {
                    xtxts = new List <XText>();
                    foreach (var x in texts)
                    {
                        XText y = x as XText;
                        if (y != null)
                        {
                            xtxts.Add(y);
                        }
                    }
                }
            }
            return(xtxts);
        }