Hi,
I had a function to compare two XML files within a project . Now I need to change that into a commandline exe in such a way that it whouls accept two params from the Command line. I have changed it .. but I am getting some errorr
ValidatorUpg.Va lidatorUpg.Comp areXMLFiles(str ing, string, System.Xml.XmlD ocument, System.Xml.XmlD ocument)' cannot be accessed with an instance reference; qualify it with a type name instead
Error 10 Cannot create an instance of the static ValidatorUpg.cs
Error 9 Cannot declare variable of static type ValidatorUpg.cs
I had a function to compare two XML files within a project . Now I need to change that into a commandline exe in such a way that it whouls accept two params from the Command line. I have changed it .. but I am getting some errorr
ValidatorUpg.Va lidatorUpg.Comp areXMLFiles(str ing, string, System.Xml.XmlD ocument, System.Xml.XmlD ocument)' cannot be accessed with an instance reference; qualify it with a type name instead
Error 10 Cannot create an instance of the static ValidatorUpg.cs
Error 9 Cannot declare variable of static type ValidatorUpg.cs
Code:
namespace ValidatorUpg
{
static class ValidatorUpg
{
static void Main(string[] args)
{
if (args.Length == 0)
{
return;
}
else
{
ValidatorUpg upgrade = new ValidatorUpg();
Console.WriteLine("Hai");
string oFileName = args[0];
string fFileName = args[1];
//XmlDocument Source;
// XmlDocument Target;
XmlDocument Source = new XmlDocument();
XmlDocument Target = new XmlDocument();
Source.Load(oFileName);
Target.Load(fFileName);
string rootSource = Source.FirstChild.Name.ToString();
upgrade.CompareXMLFiles(args[0],args[1],Source,Target);
}
}
public static void CompareXMLFiles(string oFileName,string fFileName,XmlDocument Source,XmlDocument Target)
{
foreach (XmlNode ChNode1 in Source.FirstChild.ChildNodes)
{
//use below if codition if u need to check the sub nodes
if (ChNode1.HasChildNodes == true)
{
foreach (XmlNode ChNode in ChNode1.ChildNodes)
{
//CreatePath(ChNode);
CompareLower(ChNode, oFileName, fFileName, Target);
}
}
CompareLower(ChNode1, oFileName, fFileName, Target);
}
}
public static void CompareLower(XmlNode NodeName, string oFileName, string fFileName, XmlDocument Target)
{
Boolean flag = false; // node is there
string Path = CreatePath(NodeName);
XmlNodeList selectnodeslist = Target.SelectNodes(Path);
if (selectnodeslist.Count == 0)
{
insertNode(NodeName, fFileName, Target);
}
else
{
foreach (XmlNode selectnode in selectnodeslist)
{
----------------
-------------
if (flag == false)
{
insertNode(NodeName, fFileName, Target);
-------------------
---------------------
}
}
}
public static void insertNode(XmlNode Node, string fFile,XmlDocument Target)
{
-------------
}
public static string CreatePath(XmlNode Node)
{
-----------
}
}
}
Comment