我有一个代码,它将读取一些xml文件.我尝试了不同的方法来解决这个问题,但不能.我也尝试这样编码:
Namespace my = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-01-11T08:31:30";
XElement myEgitimBilgileri = XDocument.Load(@"C:\25036077.xml").Element("my:"+ "Egitim_Bilgileri");
Run Code Online (Sandbox Code Playgroud)
但一直都是同样的错误.这是原作:
private void button2_Click(object sender, EventArgs e)
{
XElement myEgitimBilgileri =
XDocument.Load(@"C:\25036077.xml").Element("my:Egitim_Bilgileri");
if (myEgitimBilgileri != null)
{
foreach (XElement element in myEgitimBilgileri.Elements())
{
Console.WriteLine("Name: {0}\tValue: {1}", element.Name, element.Value.Trim());
}
}
Console.Read();
}
Run Code Online (Sandbox Code Playgroud)
这是我的xml文件的路径:
<my:Egitim_Bilgileri>
<my:egitimler_sap>
<my:sap_eduname></my:sap_eduname>
<my:sap_edufaculty></my:sap_edufaculty>
<my:sap_eduprofession></my:sap_eduprofession>
<my:sap_diplomno></my:sap_diplomno>
<my:sap_edulevel></my:sap_edulevel>
<my:sap_edustartdate xsi:nil="true"></my:sap_edustartdate>
<my:sap_eduenddate xsi:nil="true"></my:sap_eduenddate>
</my:egitimler_sap>
</my:Egitim_Bilgileri>
Run Code Online (Sandbox Code Playgroud)
这是我在XML中的命名空间的路径
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-01-11T08:31:30"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-01-23T00:43:17"
Run Code Online (Sandbox Code Playgroud)