TableConfig.xml:
<?xml version="1.0" encoding="utf-8" ?>
<DataFactory Desc="TableConfig" CreateUser="" CreateDate="">
<Sql001 desc="SelectWithParm" coder="" date="">
<Sql>
<![CDATA[
SELECT *
FROM TableConfig
WHERE (UserID = @UserID) AND (PageID = @PageID) AND (TableID = @TableID)
]]>
</Sql>
<Parameters>
<Param name="UserID" SqlName="@UserID" type="nvarchar" length="10" direction="Input" />
<Param name="PageID" SqlName="@PageID" type="nvarchar" length="20" direction="Input" />
<Param name="TableID" SqlName="@TableID" type="nvarchar" length="20" direction="Input" />
</Parameters>
</Sql001>
<I0001 value="保存成功!" comment="添加数据。"/>
</DataFactory>
*********************************************************************************************
private void ReadXML1()
{
string ReadXMLSql = "";
string Path = Server.MapPath("TableConfig.xml");
string ReadXMLNode = "/DataFactory/Sql001/Sql";
XmlDocument XmlDoc = new XmlDocument();
try
{
if (File.Exists(Path))
{
XmlDoc.Load(Path);
XmlNode _XmlNode = XmlDoc.SelectSingleNode(ReadXMLNode);
if (_XmlNode != null)
{
XmlNodeReader _XmlReader = new XmlNodeReader(_XmlNode);
while (_XmlReader.Read())
{
if (_XmlReader.NodeType == XmlNodeType.CDATA)
{
ReadXMLSql = _XmlReader.Value;
}
}
}
}
}
catch
{
}
}
private void ReadXML2()
{
string ReadXML = "";
string Path = Server.MapPath("TableConfig.xml");
string ReadXMLNode = "/DataFactory/Sql001/Parameters";
XmlDocument XmlDoc = new XmlDocument();
try
{
if(File.Exists(Path))
{
XmlDoc.Load(Path);
XmlNode _XmlNode = XmlDoc.SelectSingleNode(ReadXMLNode);
if (_XmlNode != null)
{
XmlNodeReader XmlReader = new XmlNodeReader(_XmlNode);
while(XmlReader.Read())
{
XmlReader.MoveToContent();
if (XmlReader.HasAttributes)
{
for (int i = 0; i < XmlReader.AttributeCount;i++)
{
XmlReader.MoveToAttribute(i);
switch(XmlReader.Name)
{
case"SqlName":
ReadXML = XmlReader.Value;
break;
}
}
}
XmlReader.MoveToElement();
}
}
}
}
catch
{
}
}
private void ReadXML3()
{
string ReadXml = "";
string XmlPath = Server.MapPath("TableConfig.xml");
XmlTextReader _XmlRead = new XmlTextReader(XmlPath);
_XmlRead.WhitespaceHandling = WhitespaceHandling.None;
while (_XmlRead.Read())
{
if (_XmlRead.Name == "I0001" && _XmlRead.NodeType == XmlNodeType.Element)
{
_XmlRead.MoveToAttribute("value");
ReadXml = _XmlRead.Value;
}
}
}