开发者

how to fetch values from special attribute names with LINQ and XML

XML is like this:

<element customer-name="blabla" customer-identifier="blabla2">

and I'm using VB.net, doing so开发者_JAVA百科mething like this:

name = xmlstring.<element>.@customer-name 

This doesnt work, because you cannot enter "@customer-name" in the LINQ query. Is there way to escape minus sign becoming an operator?


Use angle brackets to escape the name:

Dim xmlstring = <element customer-name="blabla" customer-identifier="blabla2"/>
Dim name = xmlstring.@<customer-name>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜