I have an xml document that has a structure like so:
 <?xml version="1.0" encoding="iso-8859-1" ?> 
- <newdataset xml="version="1.0" encoding="iso-8859-1"">
- <officelist>
  <officeid>2</officeid> 
  <office>Office</office> 
  <region>BC</region> 
I would like to have the office id = 2 to be its own element. Like so
 <?xml version="1.0" encoding="iso-8859-1" ?> 
<newdataset xml="version="1.0" encoding="iso-8859-1"">
    <officelist>
      <officeid id=2/>
          <office>Office</office> 
          <region>BC</region> 
     </officeid>
   </officelist>
</newdataset>
xmlDS += offices.GetXml();
xmlDS = xmlDS.Replace(@"xml:space=""preserve""", " ");               
XmlDocument doc = new XmlDocument();
XmlNode declaration = doc.CreateNode(XmlNodeType.XmlDeclaration, null, null);
doc.LoadXml(xmlDS);
doc.Save(Response.OutputStream);
T开发者_如何学Pythonhat is my code so far... not sure how to set a child node to become a parent node
using XDocument made this a lot easier with Linq.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论