views:

13

answers:

1

I'm trying figure out if this is possible. Basically, I need to create an XElement and then add one or more siblings to that XElement, but without a parent. I'll add that list of XElements to a Parent later, but need some flexibility in building this and other lists of XElements before doing so. Is this possible?

So I would have something like:

Public items As XElement = <ItemA>Something</ItemA>

And then I need to add an element so that the result looks like:

<ItemA>Something</ItemA>
<ItemB>Something Else</ItemB>

That result is what I need to pass around as a single object. I've messed arounnd with IEnumerable(Of XElement), but there is no .Add.

Any thoughts?

+1  A: 

then add one or more siblings to that XElement, but without a parent

That's not going to work, elements are only siblings because they share a Parent ...

You'll have to use a temporary parent that you later change or replace.

You can of course use any collection (List<XElement>) to keep a list that you later turn into a list of siblings. Not clear what your problem with that is.

Henk Holterman