Just a quick check really.
I have an XML file that I will be searching using Linq to XML. My only issue is, the XML that my users will be supplying can either use Long Code tags, or Short Code tags, e.g.
<FromPerson>Joe Bloggs</FromPerson> – Long Code
OR
<m175>Joe Bloggs</m175> – Short Code
Here is a snippet of my code to show how I currently search the document (currently only searching using long codes):
prod.ProductID = product.Elements("ProductIdentifier").First(t => (t.Element("ProductIDType").Value == "45" || t.Element("ProductIDType").Value == "21")).Element("IDValue").Value;
So, the element ‘ProductIdentifier’ can either be that, or ‘b221’.
Is just simply a case of putting an IF statement to evaluate if the XML tag is either long or short code, then get the value OR is there any quicker, more efficient way of doing this?
If you don’t care about the order you can just query for both and join the results like this:
EDIT
If you do care about the order of elements you can use the query below: