I'm modifying some legacy code and need to parse/write to XML with C#. I'm trying to set the value of a nested element but am not getting any joy. It should be very simple but I'm not sure what I'm doing wrong.
Here is the XML template:
<my:productReport>
<my:productId>1</my:productId>
<my:company>MyCompany</my:company>
<my:productPerson>
<my:productPersonId xsi:nil="true"></my:productPersonId>
<my:productPersonName></my:productPersonName>
</my:productedBy>
</my:productReport>
I can set the company no problem with:
XElement companyEle = doc.Root.Element(myNameSpace + "company");
companyEle.Value = value;
But how can I add a product person ID and Name? There may be more than one personID/personName elements to be added.