I have an xml,like this :
<advReqData>
<sessionid></sessionid>
<akc190></akc190>
<meds>
<med>
<idx></idx>
<alc400></alc400>
</med>
</meds>
</advReqData>
I would like to using linq to xml make XML into the following structure:
<advReqData>
<sessionid></sessionid>
<akc190></akc190>
<meds>
<med>
<idx></idx>
<alc400></alc400>
</med>
<med>
<idx></idx>
<alc400></alc400>
</med>
</meds>
</advReqData>
That is, in the meds node under the addition of a new med node, the new med node and the original document med node structure is the same.
How do I do it?
This will get the first element in "meds" and then add it to the end
var fn = xelement.Element("meds").FirstNode;
xelement.Element("meds").Add(fn);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.