使用C#,LINQ从xml字符串读取子节点 - http://testserver.windows.net/Players(PartitionKey='zzz',RowKey='000125') 2014-04-30T00:53:42Z - - - zzz 000125 2014-04-30T00:04:02.9193525Z 黑色 测试注释
如何使用C#或LINQ读取“m:properties”子体。使用C#,LINQ从xml字符串读取子节点 - http://testserver.windows.net/Players(PartitionKey='zzz',RowKey='000125') 2014-04-30T00:53:42Z - - - zzz 000125 2014-04-30T00:04:02.9193525Z 黑色 测试注释,c#,linq,c#-4.0,xml-parsing,linq-to-xml,C#,Linq,C# 4.0,Xml Parsing,Linq To Xml,如何使用C#或LINQ读取“m:properties”子体。 这个xml字符串存储在XElement类型的变量中我认为这可以向您展示如何使用Linq转换xml 如果还有什么问题,只需调试一下,看看L2X操作会带来什么,然后通过数据树再深入一步。我认为这可以向您展示如何使用Linq转换XML 如果还有什么问题,只需调试一下,看看L2X操作会带来什么,然后通过数据树再深入一步。使用Linq2XML - <entry xml:base="http://testserver.windows.n
这个xml字符串存储在XElement类型的变量中我认为这可以向您展示如何使用Linq转换xml
如果还有什么问题,只需调试一下,看看L2X操作会带来什么,然后通过数据树再深入一步。我认为这可以向您展示如何使用Linq转换XML 如果还有什么问题,只需调试一下,看看L2X操作会带来什么,然后通过数据树再深入一步。使用Linq2XML
- <entry xml:base="http://testserver.windows.net/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:etag="W/"datetime'2015-08-30T00%3A04%3A02.9193525Z'"">
<id>http://testserver.windows.net/Players(PartitionKey='zzz',RowKey='000125')</id>
<category term="testServer.Players" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Players" href="Players(PartitionKey='zzz',RowKey='000125')" />
<title />
<updated>2014-04-30T00:53:42Z</updated>
- <author>
<name />
</author>
- <content type="application/xml">
- <m:properties>
<d:PartitionKey>zzz</d:PartitionKey>
<d:RowKey>000125</d:RowKey>
<d:Timestamp m:type="Edm.DateTime">2014-04-30T00:04:02.9193525Z</d:Timestamp>
<d:Name>Black color</d:Name>
<d:Comments>Test comments</d:Comments>
</m:properties>
</content>
</entry>
使用Linq2XML
- <entry xml:base="http://testserver.windows.net/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:etag="W/"datetime'2015-08-30T00%3A04%3A02.9193525Z'"">
<id>http://testserver.windows.net/Players(PartitionKey='zzz',RowKey='000125')</id>
<category term="testServer.Players" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Players" href="Players(PartitionKey='zzz',RowKey='000125')" />
<title />
<updated>2014-04-30T00:53:42Z</updated>
- <author>
<name />
</author>
- <content type="application/xml">
- <m:properties>
<d:PartitionKey>zzz</d:PartitionKey>
<d:RowKey>000125</d:RowKey>
<d:Timestamp m:type="Edm.DateTime">2014-04-30T00:04:02.9193525Z</d:Timestamp>
<d:Name>Black color</d:Name>
<d:Comments>Test comments</d:Comments>
</m:properties>
</content>
</entry>
var xDoc = XDocument.Load(filename);
var dict = xDoc.Descendants("m:properties")
.First()
.Attributes()
.ToDictionary(x => x.Name, x => x.Value);
var xDoc = XDocument.Load(filename);
var dict = xDoc.Descendants("m:properties")
.First()
.Attributes()
.ToDictionary(x => x.Name, x => x.Value);
您可以使用
XNamespace
+“元素本地名称”
的组合来引用命名空间中的元素,例如:
XmlNamespaceManager NamespaceManager = new XmlNamespaceManager(new NameTable());
NamespaceManager.AddNamespace("base", "http://testserver.windows.net/");
NamespaceManager.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
NamespaceManager.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
NamespaceManager.AddNamespace("ns", "http://www.w3.org/2005/Atom"); XDocument doc = XDocument.Parse(XElement);
var properties = doc.XPathSelectElement("/ns:entry/ns:content/m:properties", NamespaceManager);
XElement-myxelement=XElement.Parse(“这里是您的XML字符串”);
Xm=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
List properties=myxelement.substands(m+“properties”).ToList();
您可以使用XNamespace
+“元素本地名称”
的组合来引用命名空间中的元素,例如:
XmlNamespaceManager NamespaceManager = new XmlNamespaceManager(new NameTable());
NamespaceManager.AddNamespace("base", "http://testserver.windows.net/");
NamespaceManager.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
NamespaceManager.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
NamespaceManager.AddNamespace("ns", "http://www.w3.org/2005/Atom"); XDocument doc = XDocument.Parse(XElement);
var properties = doc.XPathSelectElement("/ns:entry/ns:content/m:properties", NamespaceManager);
XElement-myxelement=XElement.Parse(“这里是您的XML字符串”);
Xm=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
List properties=myxelement.substands(m+“properties”).ToList();
在收款时,还有一个问题。我刚刚发布了一个新问题,还有一个问题是关于收集的问题。我刚刚发布了一个新问题