embedded element in xml literal query - child axis

88 views Asked by At

Is it possible to query an XML Literals statement with an embedded expression for the name of an XElement on a child axis?

For example, this works when using an extension method:

Dim clrValue As String = "green"
Dim el As XElement = Source...<clrScheme>.Elements(clrValue).FirstOrDefault

But as an embedded expression, it doesn't work:

Dim clrValue As String = "blue"
Dim el As XElement = Source...<clrScheme>.<<%= clrValue %>>.FirstOrDefault

The difference is .Elements(clrValue). vs .<<%= clrValue %>>.. The IDE hover-over-<<%... errors I'm getting are:

  1. XML Name Expected
  2. '>' expected
  3. Expression expected
  4. Character is not valid

There is no documentation to say that I can use an embedded expression as an XElement name in a child axis, but there also isn't any document to say that I can't. Is this even possible and I'm just missing something, like a processing directive?

0

There are 0 answers