XML文件数据
<xml version="1.0" encoding="utf-8"?>
<Module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Table="" Type="Process Start" ReadOnly="false" xmlns="http://localhost/License2000/xml/ModuleSchema.xsd">
<Attributes>...</Attributes>
<Clients>
<Client Name="*">
<Processes>
<Process Name="ren">...</Process>
<Process Name="dup">...</Process>
<Process Name="DEM">...</Process>
<Process Name="LAC">...</Process>
<Process Name="APP">
<Agencies>
<Agency Name="1">
<Professions>
<Profession Name="4">
<LicenseTypes>
<LicenseType Name="202">
<Controls Role="*">
<Control Visible="true" Type="com.sac.eLicense.Controls.Label" ReadOnly="false" Required="false" Value="<p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Arial","sans-serif"'>Please
read the following information and requirements for initial licensure as an
associate broker standard carefully before proceeding with the online process.</span></b></p>

<p class=MsoNormal><b><u><span style='font-size:11.0pt;font-family:"Arial","sans-serif"'>If
you have ever held a Broker license in Pennsylvania please STOP. </span></u></b><b><u><span
style='font-size:11.0pt;font-family:"Arial","sans-serif"'>DO NOT CONTINUE.
Contact the Commission for instructions.</span></u></b></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Arial","sans-serif"'>Please
complete all items in the checklist on the left-side of the screen.<span
style='color:red'>&nbsp; </span>Each item in the checklist must be completed
before you can pay the required fee and submit the application.&nbsp; Upon
completing each checklist item a checkmark will appear in the box next to the
item</span></p>

<p class=MsoNormal><b><u><span style='font-size:11.0pt;font-family:"Arial","sans-serif"'>Examination:</span></u></b><span
style='font-size:11.0pt;font-family:"Arial","sans-serif"'>&nbsp; A passing
score on the Pennsylvania (state) portion and the national (general) portion of
the broker examination within the past three years OR in lieu of the national
(general) portion of the examination have been licensed&nbsp;and active as a
real estate broker in another jurisdiction within the past five
years. </span></p>

<p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Arial","sans-serif"'>*Licensees
who wish to use and advertise a nickname for their first name shall include the
nickname on their licensure applications or biennial renewal applications. </span></b></p>
<br/><br/>" PageRow="0" PageColumn="0" Rowspan="1" Colspan="1" CID="AppInstructionsLabel" System="false" NodeLevel="License Type">
<Attributes>
<Attribute Name="class" Value="label" />
</Attributes>
</Control>
<Control Visible="true" Type="com.sac.eLicense.Controls.HyperLink" ReadOnly="false" Required="false" Value="Next..." PageRow="2" PageColumn="0" Rowspan="1" Colspan="1" CID="hyperlink_next" System="false" NodeLevel="License Type">
<Attributes>
<Attribute Name="href" Value="Demographics.aspx" />
</Attributes>
</Control>
</Controls>
</LicenseType>
.
.
.
</LicenseTypes>
</Profession>
</Professions>
</Agency>
</Agencies>
</Process>
</Processes>
</Client>
</Clients>
</Module>
我需要在Process下面添加以下节点,其中Name =“APP”对于它下面显示的每种许可类型。它必须是Controls节点的子节点;即其他控制节点的兄弟。
<Control Visible="true" Type="com.sac.eLicense.Controls.Label" ReadOnly="false" Required="false" Value="<body>

<p><font face="Arial" size="3"><b>TEST LABEL</b></font></p>
<p class="MsoNormal" align="center" style="text-align:center"><b><font face="Arial" size="2"><span style="mso-bidi-font-size: 12.0pt">&nbsp;<o:p>
</o:p>
</span></font></b></p>
<font face="Arial" size="2">
<span style="mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><br clear="all" style="mso-special-character:line-break;
page-break-before:always">
</span>

</font>
</body>" PageRow="0" PageColumn="0" Rowspan="1" Colspan="1" CID="AppInstructionsLabel" System="false" NodeLevel="License Type">
<Attributes>
<Attribute Name="class" Value="label" />
</Attributes>
</Control>
我已经使用以下代码导航到进程名称=“APP”,但是从那里我无法再根据上面的示例选择Controls节点并添加子节点。这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.XPath;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\Users\c-jerbaker\Desktop\ProcessStart.xml");
XmlNodeList processNodes = doc.GetElementsByTagName("Process");
foreach (XmlNode processNode in processNodes)
{
XmlAttributeCollection attributeCollection = processNode.Attributes;
foreach (XmlAttribute attribute in attributeCollection)
{
if (attribute.Value == "APP")
{
XmlNodeList controlNodes = processNode.SelectNodes("Controls");
foreach (XmlNode controlNode in controlNodes)
//{
// XmlNode node = doc.CreateElement("Control");
// XmlAttribute attribute2 = doc.CreateAttribute("Visible");
// attribute2.Value = "true";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("Type");
// attribute2.Value = "com.sac.eLicense.Controls.Label";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("ReadOnly");
// attribute2.Value = "false";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("Required");
// attribute2.Value = "false";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("Value");
// attribute2.Value = "<body>

<p><font face="Arial" size="3"><b>TEST LABEL</b></font></p>
<p class="MsoNormal" align="center" style="text-align:center"><b><font face="Arial" size="2"><span style="mso-bidi-font-size: 12.0pt">&nbsp;<o:p>
</o:p>
</span></font></b></p>
<font face="Arial" size="2">
<span style="mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><br clear="all" style="mso-special-character:line-break;
page-break-before:always">
</span>

</font>
</body>";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("PageRow");
// attribute2.Value = "0";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("PageColumn");
// attribute2.Value = "0";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("Rowspan");
// attribute2.Value = "2";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("Colspan");
// attribute2.Value = "1";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("CID");
// attribute2.Value = "AppInstructionsLabel";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("System");
// attribute2.Value = "false";
// node.Attributes.Append(attribute2);
// attribute2 = doc.CreateAttribute("NodeLevel");
// attribute2.Value = "LicenseType";
// node.Attributes.Append(attribute2);
// controlNode.AppendChild(node);
// doc.Save("ProcessStart.xml");
// Console.ReadLine();
//}
}
}
}
}
}
}
评论部分是我尝试构建要添加的节点的地方,但是无法访问那些控制台节点我甚至无法开始测试我是否正在执行下一部分。我一直在网上搜索试图找出更多关于XML导航和创建的信息,但此时我很难过。如果有人可以指出我正确的方向或向我解释我不理解XML我会很感激。
感谢。