简体   繁体   中英

Any way to use XML axis properties in C#?

Is there any way at all, by using some imports or usings, to use XML axis properties in C#?

I mostly work in VB, and am so used to being able to just query XML with
(from xel in xdoc.<names>)

Having to do a little work in C# now, it is annoying to have to write it out verbosely as
(from xel in xdoc.Elements("names")) .

It doesn't seem like a big thing, I know, but each element reference this way is 5x as many characters, and so much more verbose. It is a drag to type and read.

If there isn't, I guess I'm at a loss, but hopefully there is some way to use them? Using Visual Studio 2012.

I think there isn't.

But there are many ways to process XML with C#. I think LINQ2XML ist the closest to what you're looking for.

Se also LINQ to XML vs. Other XML Technologies , to get an overview.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM