Feedjit

Articles for you

Showing posts with label XPATH. Show all posts
Showing posts with label XPATH. Show all posts

Tuesday, August 20, 2013

How to Get All Uparas from the XML using XPATH and C#. XSL XSLT XPATH XML Using Regular Expression REGEX

using System.IO;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Xsl;
namespace XML_Parser
{
    class Program
    {
        public static Hashtable hash_table = new Hashtable();
        static void Main(string[] args)
        {
            string path = @"C:\Documents and Settings\saqib\My Documents\OMessenger\Received files\KOKODA-With Index.xml";
            string pattern = @"[a-z][a-z]+\.[a-z]+";
            XslCompiledTransform myxsl = new XslCompiledTransform();
            myxsl.Load("XSLTFile1.xslt");
            myxsl.Transform(path, "To_Table.html");
          //  var xDocument = XDocument.Load(path);
          //  string xmll = xDocument.ToString();
            XmlDocument xml =new XmlDocument();
            xml.Load(path);

XmlNodeList xnList = xml.SelectNodes("//upara");
//Console.WriteLine(xnList.Count);
foreach (XmlNode xn in xnList)

{
    //Console.WriteLine(xn.InnerText);
    string upara = xn.InnerText;
 
    MatchCollection matches = Regex.Matches(upara, pattern);
    foreach (Match match in matches)
    {
        foreach (Capture capture in match.Captures)
        {
            Console.WriteLine("Index={0}, Value={1}", capture.Index, capture.Value);
            hash_table.Add(capture.Index, capture.Value);
        }
    }

}
Console.ReadKey();
        }          
                    }
                }
         
        

Read More

Articles for you