I have two XResult, Xtemp variables of type XElement.
I am trying to extract all the elements <vehicle>from Xtemp and add them to Xresult's <vehicles>.
It seems that in Xtemp it <vehicle>will sometimes appear under <vehicles>, and sometimes it will by itself.
XResult.Descendants(xmlns + "Vehicles").FirstOrDefault().Add(
XTemp.Descendants(xmlns + "Vehicles").Nodes().Count() > 0
? XTemp.Descendants(xmlns + "Vehicles").Nodes()
: (XTemp.Descendants(xmlns + "SearchDataset").FirstOrDefault().Descendants(xmlns + "Vehicle")));
In the above code, I use the ternary operator to check if there are <vehicles>children, then all the rest to get all the elements <vehicle>.
This leads to an error: without an imperial conversion between System.Collections.Generic.IEnumerable<System.Xml.Linq.XNode>andSystem.Collections.Generic.IEnumerable <System.Xml.Linq.XElement>
Can any body help me fix this. Thanks in advance. BB.
source
share