0

XML File below. Looking to be able to read from and write to the below file.

Using the below code I am able to SEARCH for a specific pagename node

`XDocument xmldoc = XDocument.Load(path); 
 metadata m = new metadata();
 XElement emp = xmldoc.Descendants("data").FirstOrDefault(p => p.Element("pagename").Value == pagename);

        if (emp != null)
        {
           //How to populate each child node
           // dctermscreator.en = this
           // dctermscreator.fr = this

           //so on
        }`

 `<?xml version="1.0" encoding="UTF-8" ?>
 <root>
 <data>
  <pagename>default</pagename>
  <metadata>
    <desc>
      <en>eng desc</en>
      <fr>desc fra</fr>
    </desc>
    <dctermscreator>
      <en>eng desc</en>
      <fr>desc fra</fr>
    </dctermscreator>
    <dctermssubject>
      <en>eng desc</en>
      <fr>desc fra</fr>
    </dctermssubject>
  </metadata>
 </data>
 </root>`
0

1 Answer 1

0

I think XmlSerializer is what you need just call deserialize and it will do all work for you. You can also use CreateReader to get xml reader from XElement

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.