XML例如:我怎样才能获得文字,在我的XML属性值
<?xml version="1.0" encoding="utf-8" ?>
<brand name="brand1" num_brand="118" enabled="True">
<price>
<nodePattern>pattern</nodePattern>
<attribute type="text" ></attribute>
<treatment enabled="1" type="Regex">reg</treatment>
</price>
<title>
<nodePattern>pattern</nodePattern>
<attribute type="text" ></attribute>
<treatment enabled="1" type="Regex">reg</treatment>
</title>
</brand>
请,我怎么能得到不同的属性值和文本为我所有的不同节点(例如名称,num_brand和启用品牌,启用,输入和“reg”治疗)使用System.Xml.Linq?
谢谢!
你尝试过这么远吗?你在挣扎什么?你想如何获得这些值(在一个字符串?加载到一个类?) –
现在的问题是你的问题是什么?根据你想要的,Linq to XML很容易。例如'var x = doc.Root.Attribute(“num_brand”)。Value;'给你那个属性的文本.. – Stefan