111,126
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="gb2312"?>
<Main>
<TypeName>
<Name id="1">c#语言基础</Name>
<Name id="2">c#高级技术</Name>
<Name id="3">asp.net学习</Name>
<Name id="4">javascript学习</Name>
<Name id="5">Div+Css学习</Name>
<Name id="6">单片机了解</Name>
<Name id="7">SQL技术摘抄</Name>
<Name id="8">心情随笔</Name>
</TypeName>
<ChapterList>
</ChapterList>
</Main>
public static string ReadNodeValue(string paths)
{
StringBuilder sb = new StringBuilder();
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(paths);
XmlNodeList nodelist = xmldoc.SelectNodes("//Main/TypeName") ;
foreach (XmlNode xnd in nodelist)
{
for (int i = 0; i < xnd.ChildNodes.Count; i++)
{
sb.Append(xnd.SelectSingleNode("Name").InnerText + "|");
}
}
return sb.ToString();
}
<Name id="9">网站建设</Name>
<Name id="10">单片机学习</Name>
<Name id="11">单片机程序</Name>
<Name id="9">网站建设</Name>
<Name id="10">单片机学习</Name>
<Name id="11">单片机程序</Name>
XmlNode xn = doc.CreateNode(XmlNodeType.Element, "", "Name", "");
xn.InnerText = "网站建设";
XmlAttribute xa = doc.CreateAttribute("id");
xa.Value = "9";
xn.Attributes.Append(xa);
node.AppendChild(xn);
public static string ReadNodeValue(string paths)
{
StringBuilder sb = new StringBuilder();
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(paths);
XmlNodeList nodelist = xmldoc.SelectNodes("//Main/TypeName") ;
foreach (XmlNode xnd in nodelist)
{
foreach (XmlNode xn in xnd.ChildNodes)
{
sb.Append(xn.InnerXml + "|" + xn.Attributes["id"].Value + "|");
}
}
return sb.ToString();
}
public static string ReadNodeValue(string paths)
{
StringBuilder sb = new StringBuilder();
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(paths);
XmlNodeList nodelist = xmldoc.SelectNodes("//Main/TypeName");
foreach (XmlNode xnd in nodelist)
{
for (int i = 0; i < xnd.ChildNodes.Count; i++)
{
// sb.Append(xnd.SelectSingleNode("Name").InnerText + "|");
sb.Append(xnd.ChildNodes[i].InnerText + "|");
}
}
return sb.ToString();
}
public static string ReadNodeValue(string paths)
{
StringBuilder sb = new StringBuilder();
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(paths);
XmlNodeList nodelist = xmldoc.SelectNodes("//Main/TypeName") ;
foreach (XmlNode xnd in nodelist)
{
foreach (XmlNode xn in xnd.ChildNodes)
{
sb.Append(xn.InnerXml + "|");
}
}
return sb.ToString();
}