Пример #1
0
        private void VerifyXPath()
        {
            string Xpath = mAction.ElementLocateValue;

            try
            {
                XPathParser <XElement> xpp = new XPathParser <XElement>();
                XElement xe1 = xpp.Parse(Xpath, new XPathTreeBuilder());
                xpp.GetOKPath();

                XElement xe = new XPathParser <XElement>().Parse(Xpath, new XPathTreeBuilder());

                XmlWriterSettings ws = new XmlWriterSettings();
                {
                    ws.Indent             = true;
                    ws.OmitXmlDeclaration = true;
                }
                StringBuilder sb = new StringBuilder();
                using (XmlWriter w = XmlWriter.Create(sb, ws))
                {
                    xe.WriteTo(w);
                }

                ResultLabel.Content = sb.ToString();
            }
            catch (Exception e)
            {
                ResultLabel.Content = e.Message;
            }
        }
Пример #2
0
 static void RunTestTree(string xpathExpr)
 {
     Console.WriteLine("Original XPath: {0}", xpathExpr);
     try {
         XElement          xe = new XPathParser <XElement>().Parse(xpathExpr, new XPathTreeBuilder());
         XmlWriterSettings ws = new XmlWriterSettings(); {
             ws.Indent             = true;
             ws.OmitXmlDeclaration = true;
         }
         using (XmlWriter w = XmlWriter.Create(Console.Out, ws)) {
             xe.WriteTo(w);
         }
     } catch (XPathParserException e) {
         Console.WriteLine(e.ToString());
     }
     Console.WriteLine();
     Console.WriteLine();
 }