开发者

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

开发者 https://www.devze.com 2023-01-06 18:56 出处:网络
XML is like this: <element customer-name=\"blabla\" customer-identifier=\"blabla2\"> and I\'m using VB.net, doing so开发者_JAVA百科mething like this:

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

精彩评论

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