本文整理汇总了C#中XmlDocument.ImportNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.ImportNode方法的具体用法?C# XmlDocument.ImportNode怎么用?C# XmlDocument.ImportNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.ImportNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportNullNode
public static void ImportNullNode()
{
var xmlDocument = new XmlDocument();
Assert.Throws<InvalidOperationException>(() => xmlDocument.ImportNode(null, false));
Assert.Throws<InvalidOperationException>(() => xmlDocument.ImportNode(null, true));
}
示例2: Main
static void Main(string[] args) {
if (args.Length != 4) {
Console.WriteLine("Usage: cra.exe cert-file cert-password input-path output-path");
return;
}
String certFile = args[0];
String password = args[1];
String input = args[2];
String output = args[3];
X509Certificate2 cert = new X509Certificate2(certFile, password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(input);
var XmlToSign = new XmlDocument();
XmlToSign.LoadXml(xmlDoc.DocumentElement["Body"].OuterXml);
SignedXml signedXml = new SignedXml(XmlToSign);
signedXml.SigningKey = cert.PrivateKey;
Reference reference = new Reference();
reference.Uri = "";
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);
signedXml.AddReference(reference);
signedXml.ComputeSignature();
XmlElement xmlDigitalSignature = signedXml.GetXml();
xmlDoc.DocumentElement["Body"].AppendChild(xmlDoc.ImportNode(xmlDigitalSignature, true));
xmlDoc.Save(output);
}
示例3: ImportSignificantWhitespace
public static void ImportSignificantWhitespace()
{
var whitespace = " \t";
var tempDoc = new XmlDocument();
var nodeToImport = tempDoc.CreateSignificantWhitespace(whitespace);
var xmlDocument = new XmlDocument();
var node = xmlDocument.ImportNode(nodeToImport, true);
Assert.Equal(xmlDocument, node.OwnerDocument);
Assert.Equal(XmlNodeType.SignificantWhitespace, node.NodeType);
Assert.Equal(whitespace, node.Value);
}
示例4: ImportDocumentFragment
public static void ImportDocumentFragment()
{
var tempDoc = new XmlDocument();
var nodeToImport = tempDoc.CreateDocumentFragment();
nodeToImport.AppendChild(tempDoc.CreateElement("A1"));
nodeToImport.AppendChild(tempDoc.CreateComment("comment"));
nodeToImport.AppendChild(tempDoc.CreateProcessingInstruction("PI", "donothing"));
var xmlDocument = new XmlDocument();
var node = xmlDocument.ImportNode(nodeToImport, true);
Assert.Equal(xmlDocument, node.OwnerDocument);
Assert.Equal(XmlNodeType.DocumentFragment, node.NodeType);
Assert.Equal(nodeToImport.OuterXml, node.OuterXml);
}
示例5: SignXmlFile
// Sign an XML file and save the signature in a new file. This method does not
// save the public key within the XML file. This file cannot be verified unless
// the verifying code has the key with which it was signed.
public static void SignXmlFile(string FileName, string SignedFileName, RSA Key)
{
// Create a new XML document.
XmlDocument doc = new XmlDocument();
// Load the passed XML file using its name.
doc.Load(new XmlTextReader(FileName));
// Create a SignedXml object.
SignedXml signedXml = new SignedXml(doc);
// Add the key to the SignedXml document.
signedXml.SigningKey = Key;
// Create a reference to be signed.
Reference reference = new Reference();
reference.Uri = "";
// Add an enveloped transformation to the reference.
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);
// Add the reference to the SignedXml object.
signedXml.AddReference(reference);
// Compute the signature.
signedXml.ComputeSignature();
// Get the XML representation of the signature and save
// it to an XmlElement object.
XmlElement xmlDigitalSignature = signedXml.GetXml();
// Append the element to the XML document.
doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, true));
if (doc.FirstChild is XmlDeclaration)
{
doc.RemoveChild(doc.FirstChild);
}
// Save the signed XML document to a file specified
// using the passed string.
XmlTextWriter xmltw = new XmlTextWriter(SignedFileName, new UTF8Encoding(false));
doc.WriteTo(xmltw);
xmltw.Close();
}
示例6: OwnerDocumentOnImportedTree
public static void OwnerDocumentOnImportedTree()
{
var tempDoc = new XmlDocument();
var nodeToImport = tempDoc.CreateDocumentFragment();
nodeToImport.AppendChild(tempDoc.CreateElement("A1"));
nodeToImport.AppendChild(tempDoc.CreateComment("comment"));
nodeToImport.AppendChild(tempDoc.CreateProcessingInstruction("PI", "donothing"));
var xmlDocument = new XmlDocument();
var node = xmlDocument.ImportNode(nodeToImport, true);
Assert.Equal(xmlDocument, node.OwnerDocument);
foreach (XmlNode child in node.ChildNodes)
Assert.Equal(xmlDocument, child.OwnerDocument);
}
示例7: ImportElementDeepFalse
public static void ImportElementDeepFalse()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<elem1 child1='' child2='duu' child3='e1;e2;' child4='a1' child5='goody'> text node two text node three </elem1>");
var doc = new XmlDocument();
var imported = doc.ImportNode(xmlDocument.DocumentElement, false);
Assert.Equal(xmlDocument.DocumentElement.Name, imported.Name);
Assert.Equal(xmlDocument.DocumentElement.Value, imported.Value);
Assert.Equal(xmlDocument.DocumentElement.Prefix, imported.Prefix);
Assert.Equal(xmlDocument.DocumentElement.NamespaceURI, imported.NamespaceURI);
Assert.Equal(xmlDocument.DocumentElement.LocalName, imported.LocalName);
Assert.Equal(0, imported.ChildNodes.Count);
Assert.Equal(xmlDocument.DocumentElement.Attributes.Count, imported.Attributes.Count);
}
示例8: LoadAllForecasts
private XmlDocument LoadAllForecasts()
{
XmlDocument allForecasts = new XmlDocument();
try
{
allForecasts.Load(new XmlTextReader("http://weather.yahooapis.com/forecastrss?p=" + cityCodes[0] + "&u=c"));
XmlDocument temp = new XmlDocument();
for (int i = 1; i < cityCodes.Length; i++)
{
temp.Load(new XmlTextReader("http://weather.yahooapis.com/forecastrss?p=" + cityCodes[i] + "&u=c"));
XmlNode newChannel = allForecasts.ImportNode(temp.DocumentElement.FirstChild, true);
allForecasts.DocumentElement.AppendChild(newChannel);
}
}
catch (Exception) { }
return allForecasts;
}
示例9: AddGongbu
//��ӹ��� 0Ϊ��һ����-1������Ϊ���һ��
//����ڵ������λ�ã�
//ԭ �£�index��
// 0
//0-------
// 1
//1-------
// 2
//2-------
// 3 or -1
//--------
/// <summary>
/// ��ӹ�������ʱ����
/// </summary>
/// <param name="gongxu_index">�ڼ�������ĺ��ӣ���0��ʼ</param>
/// <param name="gongbu_index">0Ϊ��һ����-1������Ϊ���һ��</param>
/// <param name="ProcessXML">����xml</param>
/// <param name="TemplateXML">ģ��xml</param>
public static void AddGongbu(int gongxu_index, int gongbu_index, string ProcessXML, string TemplateXML)
{
try
{
XmlDocument docForm = new XmlDocument();
XmlDocument docTo = new XmlDocument();
docForm.Load(TemplateXML);
docTo.Load(ProcessXML);
string path = "/SYS_3DPPM/Gongyi/Gongxu[" + (gongxu_index+1).ToString() + "]";
XmlNodeList gongxu_nodes = docTo.SelectNodes(path);
if (gongxu_nodes.Count == 0)
{
throw new Exception("��δ֪����λ�ò��빤���ڵ㣡");
//return;
}
path = "/Template/Gongbu";
XmlNode fromNode = docForm.SelectSingleNode(path);
XmlNode newNode = docTo.ImportNode(fromNode, true);
string guid = Guid.NewGuid().ToString();
((XmlElement)newNode).SetAttribute("GUID", guid);
//�õ���������
XmlNodeList nodes = gongxu_nodes[0].SelectNodes("Gongbu");
int count = nodes.Count;
if (gongbu_index < 0 || gongbu_index > count - 1)
{
//�������
gongxu_nodes[0].AppendChild(newNode);
}
else
{
//����indexǰ
gongxu_nodes[0].InsertBefore(newNode, nodes[gongbu_index]);
}
UpdateGongxuGongbuhao(docTo);
docTo.Save(ProcessXML);
}
catch (System.Exception ex)
{
NXFun.MessageBox(ex.Message);
}
}
示例10: Update3dppm
//���¾ɰ湤��XML
/// <summary>
/// ���¾ɰ湤��XML 0�°治���� 1 �ɰ���³ɹ� 2 �ɰ����ʧ��
/// </summary>
/// <param name="xmlfile">�ɰ湤��XML</param>
/// <param name="templateXml">�°湤��XMLģ��</param>
/// <returns>0�°治���� 1 �ɰ���³ɹ� 2 �ɰ����ʧ��</returns>
public static int Update3dppm(string xmlfile,string templateXml)
{
XmlDocument olddoc = new XmlDocument();
olddoc.Load(xmlfile);
XmlNode root = olddoc.SelectSingleNode("/SYS_3DPPM");
XmlElement xe_root = root as XmlElement;
string version = xe_root.GetAttribute("version");
if (version == "2.0")
{
//�°�
return 0;
}
try
{
XmlNodeList nodes_old = olddoc.SelectNodes("/SYS_3DPPM/Process");
if (nodes_old.Count == 0)
{
return 2;
}
//����xml����
string newfile = xmlfile + ".bak";
File.Copy(NXFun.TDPPMPath + NXFun.ProcessXML, newfile, true);
XmlDocument newdoc = new XmlDocument();
newdoc.Load(newfile);
XmlNode new_gongyi_node = newdoc.SelectSingleNode("/SYS_3DPPM/Gongyi");
XmlDocument templatedoc = new XmlDocument();
templatedoc.Load(templateXml);
XmlNode gongxu_node = templatedoc.SelectSingleNode("/Template/Gongxu[@Type='��ͨ����']");
XmlNode gongbu_node = templatedoc.SelectSingleNode("/Template/Gongbu");
XmlNode zigongbu_node = templatedoc.SelectSingleNode("/Template/Zigongbu");
XmlNode ylt_node = templatedoc.SelectSingleNode("/Template/YLT");
//��ӹ�����Ϣ
string model = ((XmlElement)(nodes_old[0])).GetAttribute("DesignModel");
XmlNode node = newdoc.SelectSingleNode("/SYS_3DPPM/Gongyi/Model");
((XmlElement)node).SetAttribute("filename", model);
XmlElement xe_old = nodes_old[0].SelectSingleNode("Information") as XmlElement;
XmlElement xe_new = newdoc.SelectSingleNode("/SYS_3DPPM/Gongyi/Information") as XmlElement;
foreach(XmlAttribute xa in xe_old.Attributes)
{
string name = xa.Name;
if (xa.Name.Contains("edit_"))
{
name = xa.Name.Substring(xa.Name.IndexOf("_") + 1, xa.Name.Length - xa.Name.IndexOf("_") - 1);
}
xe_new.SetAttribute(name, xa.Value);
}
#region ��ӹ��������ӹ�����Ϣ
//��ӹ�����Ϣ
nodes_old = olddoc.SelectNodes("/SYS_3DPPM/Process/Procedure");
foreach (XmlElement xe_gongxu in nodes_old)
{
//���һ������
XmlNode newnode = newdoc.ImportNode(gongxu_node, true);
XmlNode new_gongxu = new_gongyi_node.AppendChild(newnode);
model = xe_gongxu.GetAttribute("Model");
((XmlElement)new_gongxu.SelectSingleNode("Model")).SetAttribute("filename", model);
XmlElement xe_gongxu_information = new_gongxu.SelectSingleNode("Information") as XmlElement;
foreach (XmlAttribute xa in xe_gongxu.SelectSingleNode("Information").Attributes)
{
string name = xa.Name;
if (xa.Name.Contains("edit_"))
{
name = xa.Name.Substring(xa.Name.IndexOf("_") + 1, xa.Name.Length - xa.Name.IndexOf("_") - 1);
}
xe_gongxu_information.SetAttribute(name, xa.Value);
}
//��ӹ�����Ϣ
XmlNodeList nodes_gongbu_old = xe_gongxu.SelectNodes("StepGroup/Step");
foreach (XmlElement xe_gonbu in nodes_gongbu_old)
{
//���һ������
XmlNode newnode_gongbu = newdoc.ImportNode(gongbu_node, true);
XmlNode new_gongbu = new_gongxu.AppendChild(newnode_gongbu);
XmlElement xe_gongbu_information = new_gongbu.SelectSingleNode("Information") as XmlElement;
foreach (XmlAttribute xa in xe_gonbu.SelectSingleNode("Information").Attributes)
{
string name = xa.Name;
if (name == "edit_gongbu_gongbuhao")
{
name = "gongbu_gongbuhao";
}
else if (name == "edit_gongbu_gongbumingcheng")
{
name = "gongbu_gongbuneirong";
}
else if (name == "edit_gongbu_renju")
{
name = "gongbu_renju";
}
else if (name == "edit_gongbu_liangju")
//.........这里部分代码省略.........
示例11: SetModelAttr
public static bool SetModelAttr(int a,int b,string name,string description,string xmlfile,string TemplateXML)
{
try
{
XmlDocument mydoc = new XmlDocument();
mydoc.Load(xmlfile);
string path = "";
if (a == 0 && b == 0)
{
//�����ģ��
path = "/SYS_3DPPM/Gongyi/Model";
XmlElement node = (XmlElement)mydoc.SelectSingleNode(path);
node.SetAttribute("filename", name);
node.SetAttribute("description", description);
mydoc.Save(xmlfile);
return true;
}
else if (a == 0 && b > 0)
{
//�Ĺ���ģ��
path = "/SYS_3DPPM/Gongyi/Gongxu[" + b.ToString() + "]/Model";
XmlElement node = (XmlElement)mydoc.SelectSingleNode(path);
node.SetAttribute("filename", name);
node.SetAttribute("description", description);
mydoc.Save(xmlfile);
return true;
}
else if (a == 1 && b == 0)
{
//��Ӹ���ģ��
path = "/SYS_3DPPM/Gongyi/FuModels";
XmlNode node = mydoc.SelectSingleNode(path);
XmlDocument docForm = new XmlDocument();
docForm.Load(TemplateXML);
XmlNode fromNode = docForm.SelectSingleNode("/Template/FuModel");
XmlNode newNode = mydoc.ImportNode(fromNode, true);
newNode = node.AppendChild(newNode);
XmlElement xe = newNode as XmlElement;
xe.SetAttribute("filename", name);
xe.SetAttribute("description", description);
mydoc.Save(xmlfile);
return true;
}
else if (a == 1 && b > 0)
{
//�ĸ���ģ��
path = "/SYS_3DPPM/Gongyi/FuModels/FuModel[" + b.ToString() + "]";
XmlElement node = (XmlElement)mydoc.SelectSingleNode(path);
node.SetAttribute("filename", name);
node.SetAttribute("description", description);
mydoc.Save(xmlfile);
return true;
}
else if (a == 2 && b == 0)
{
//�������ͼ
path = "/SYS_3DPPM/Gongyi/YLTs";
XmlNode node = mydoc.SelectSingleNode(path);
XmlDocument docForm = new XmlDocument();
docForm.Load(TemplateXML);
XmlNode fromNode = docForm.SelectSingleNode("/Template/YLT");
XmlNode newNode = mydoc.ImportNode(fromNode, true);
newNode = node.AppendChild(newNode);
XmlElement xe = newNode as XmlElement;
xe.SetAttribute("filename", name);
xe.SetAttribute("description", description);
mydoc.Save(xmlfile);
return true;
}
else if (a == 2 && b > 0)
{
//������ͼ
path = "/SYS_3DPPM/Gongyi/YLTs/YLT[" + b.ToString() + "]";
XmlElement node = (XmlElement)mydoc.SelectSingleNode(path);
node.SetAttribute("filename", name);
node.SetAttribute("description", description);
mydoc.Save(xmlfile);
return true;
}
return false;
}
catch (System.Exception ex)
{
NXFun.MessageBox(ex.Message);
return false;
}
}
示例12: SetChildStepList
//�����ӹ�����Ϣ
/// <summary>
/// �����ӹ�����Ϣ (M,N)��M������ĵ�N������ ����1��
/// </summary>
/// <param name="a">����a</param>
/// <param name="b">����b</param>
/// <param name="childsteps">�ӹ�����Ϣ</param>
/// <param name="xmlfile">����xml</param>
/// <param name="TemplateXML">ģ��xml</param>
public static void SetChildStepList(int a, int b, List<S_ChildStep> childsteps, string xmlfile,string TemplateXML)
{
try
{
XmlDocument docTo = new XmlDocument();
XmlDocument docForm = new XmlDocument();
docForm.Load(TemplateXML);
docTo.Load(xmlfile);
string path = "/SYS_3DPPM/Gongyi/Gongxu[" + a.ToString() + "]/Gongbu[" + b.ToString() + "]";
XmlNode node = docTo.SelectSingleNode(path);
XmlNodeList nodes = node.SelectNodes("Zigongbu");
path = "/Template/Zigongbu";
XmlNode fromNode = docForm.SelectSingleNode(path);
//ɾ������ԭ�ڵ�
foreach (XmlNode xn in nodes)
{
node.RemoveChild(xn);
}
//������ӹ���
foreach (S_ChildStep childstep in childsteps)
{
XmlNode newNode = (XmlElement)docTo.ImportNode(fromNode, true);
XmlElement xe = (XmlElement)newNode.SelectSingleNode("Information");
xe.SetAttribute("zigongbu_name", childstep.name);
xe.SetAttribute("zigongbu_liangju", childstep.liangju);
xe.SetAttribute("zigongbu_renju", childstep.renju);
xe.SetAttribute("zigongbu_beizhu", childstep.beizhu);
node.AppendChild(newNode);
}
docTo.Save(xmlfile);
}
catch (System.Exception ex)
{
NXFun.MessageBox(ex.Message);
}
}
示例13: SignXML
//-------------------------------------------------------------------------------------------
private string SignXML(string xml)
{
// Signing XML Documents: http://msdn.microsoft.com/en-us/library/ms229745.aspx
var rsaKey = new RSACryptoServiceProvider();
string sales_licensekeys_privatekey = ConfigurationManager.AppSettings["sales_licensekeys_privatekey"];
if (!File.Exists(sales_licensekeys_privatekey))
throw new Exception("The private signing key is missing");
rsaKey.FromXmlString(System.IO.File.ReadAllText(sales_licensekeys_privatekey));
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.LoadXml(xml);
SignedXml signedXml = new SignedXml(doc);
signedXml.SigningKey = rsaKey;
// Create a reference to be signed.
Reference reference = new Reference();
reference.Uri = ""; // set to "" to sign the entire doc
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);
signedXml.AddReference(reference);
signedXml.ComputeSignature();
XmlElement xmlDigitalSignature = signedXml.GetXml();
doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, true));
MemoryStream ms = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(ms, new UTF8Encoding(false));
writer = new XmlTextWriter(ms, new UTF8Encoding(false));
//writer.Formatting = Formatting.Indented;
doc.WriteContentTo(writer);
writer.Flush();
ms.Position = 0;
StreamReader reader = new StreamReader(ms);
return reader.ReadToEnd();
}
示例14: ConfigureDeepLinks
//.........这里部分代码省略.........
0x00, 0x00, 0x00, 0x00, 0x00
});
seedsDeepLinksAar.AddEntry("R.txt", new byte[0]);
seedsDeepLinksAar.AddDirectoryByName("res");
seedsDeepLinksAar.AddEntry("AndroidManifest.xml", deepLinkAndroidManifestContent, Encoding.ASCII);
seedsDeepLinksAar.Save(Path.Combine(Application.dataPath, "Plugins/Android/SeedsDeepLinks.aar"));
}
#elif UNITY_4_5 || UNITY_4_6
// For Unity3D 4.x only AndroidManifest.xml modification is needed
var androidManifestPath = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml");
var androidNS = "http://schemas.android.com/apk/res/android";
var androidManifestDocument = new XmlDocument();
androidManifestDocument.Load(androidManifestPath);
var manifestNsManager = new XmlNamespaceManager(androidManifestDocument.NameTable);
manifestNsManager.AddNamespace("android", androidNS);
var deepLinkActivityXPath =
"/manifest/application/activity[@android:name='com.playseeds.unity3d.androidbridge.DeepLinkActivity']";
var deepLinkActivityNode = androidManifestDocument.SelectSingleNode(deepLinkActivityXPath, manifestNsManager);
if (deepLinkActivityNode == null)
{
var applicactionNode = androidManifestDocument.SelectSingleNode("/manifest/application");
var deepLinkAndroidManifest = new XmlDocument();
deepLinkAndroidManifest.LoadXml(deepLinkAndroidManifestContent);
manifestNsManager = new XmlNamespaceManager(androidManifestDocument.NameTable);
manifestNsManager.AddNamespace("android", androidNS);
deepLinkActivityNode = deepLinkAndroidManifest.SelectSingleNode(deepLinkActivityXPath, manifestNsManager);
deepLinkActivityNode = androidManifestDocument.ImportNode(deepLinkActivityNode, true);
applicactionNode.AppendChild(deepLinkActivityNode);
}
var dataNode = deepLinkActivityNode.SelectSingleNode("intent-filter/data");
var schemeAttribute = dataNode.Attributes.GetNamedItem("scheme", androidNS);
var hostAttribute = dataNode.Attributes.GetNamedItem("host", androidNS);
var pathPrefixAttribute = dataNode.Attributes.GetNamedItem("pathPrefix", androidNS);
schemeAttribute.Value = scheme;
hostAttribute.Value = host;
pathPrefixAttribute.Value = pathPrefix;
androidManifestDocument.Save(androidManifestPath);
#else
#error Unsupported Unity3D version, please contact support.
#endif
}
else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iPhone)
{
var seedsSettingsXml = new XmlDocument();
var seedsSettingsFilename = Path.Combine(Application.dataPath, "../ProjectSettings/SeedsSDK.xml");
if (File.Exists(seedsSettingsFilename))
seedsSettingsXml.Load(seedsSettingsFilename);
var seedsSdkNode = seedsSettingsXml.SelectSingleNode("SeedsSDK");
if (seedsSdkNode == null)
{
seedsSdkNode = seedsSettingsXml.CreateElement("SeedsSDK");
seedsSettingsXml.AppendChild(seedsSdkNode);
}
示例15: GetCurrentSiteConfig
/// <summary>
/// This method gets the site config and editkey from the database. It then re populates the drop down with the current sections
/// </summary>
private void GetCurrentSiteConfig()
{
// Get the current preview config and edit key
using (IDnaDataReader reader = _basePage.CreateDnaDataReader("fetchpreviewsiteconfig"))
{
// Add the site id
reader.AddParameter("SiteID", _basePage.CurrentSite.SiteID);
reader.Execute();
// Get the config and edit key
if (reader.HasRows && reader.Read())
{
_editKey = reader.GetGuidAsStringOrEmpty("EditKey");
XmlDocument xDoc = new XmlDocument();
string siteConfig = reader.GetStringNullAsEmpty("Config");
// Check to make sure we have a config for this site
if (siteConfig.Length == 0)
{
// Nothing in the database, setup the base tag
if (!_barlequeRedesign)
{
siteConfig = "<SITECONFIG></SITECONFIG>";
}
else
{
siteConfig = "<SITECONFIG><" + _v2TagName + "></" + _v2TagName + "></SITECONFIG>";
}
}
try
{
xDoc.LoadXml(Entities.GetEntities() + siteConfig);
_currentSiteConfig = xDoc.ImportNode(xDoc.FirstChild.NextSibling, true);
}
catch (XmlException ex)
{
// Had a problem parsing the siteconfig
message.Text = "\n\rThe following error occured - " + ex.Message;
message.Font.Bold = true;
message.ForeColor = System.Drawing.Color.Red;
message.Visible = true;
_basePage.Diagnostics.WriteExceptionToLog(ex);
}
}
}
// Check to make sure we got an edit key.
if (_editKey == null)
{
// Tell the user.
message.Text = "\n\rFailed to get an edit key for this site!";
message.Font.Bold = true;
message.ForeColor = System.Drawing.Color.Red;
message.Visible = true;
}
else
{
// Now Initialise the dropdwon with the config
PopulateDropDown();
// Get the index of the select item and display the XML for that section
Dictionary<string,string> selectedData;
if (_currentSectionStrings.Count > 0 && _currentSectionStrings.TryGetValue(dlbConfigSections.SelectedItem.Text + "0", out selectedData))
{
dlbConfigSections.SelectedIndex = 0;
string selectedText = "";
selectedData.TryGetValue(dlbConfigSections.SelectedItem.Text, out selectedText);
tbSectionXML.Text = selectedText;
}
}
}