(假设<book>节点是a节点的子节点
也就是这样的
<a>
<book>数学〈/book>
<title>题目</title>
</a>
)
XmlNodeList node = xml.SelectNodeList("a").ChildNodes//获取a的子节点
foreach(XmlNode xl in node)
{
XmlElement xe = (XmlElement) xl
if(xe.Name = book)
{
xe.InnerText = "高等数学"
}
}
$xml =<<<EOT<?xml version="1.0"?>
<root>
<section name="Section1">
<category id="Category1" name="google">
</section>
</root>
EOT
$objXML=simplexml_load_string($xml)
$objXML->section->addAttribute('city', 'abc')
echo $objXML->asXML()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)