c# - How to read an xml and write it back when you understand only part of its structuer -


i have xml may contains several types of nodes, interested in specific node types. want change nodes interested in , save result, when other nodes should unchanged.

for example xml follow:

<?xml version="1.0" encoding="utf-8"?>     <unknown>      ...      <unknown/>      <companyname>         <attrcontainer>             <attr type="string">                 <name value="'name'" />                 <value value="'attrcontainer'" />             </attr>             <unknown>               ...              <unknown/>              <subcontainer>                 <attrcontainer value="'wssmetadata'" />                 <attrcontainer>                     <attr type="string">                         <name value="'name'" />                         <value value="'attrcontainer'" />                     </attr>                     <subcontainer>                         <wssmetadata value="'afe2e194-0ce7-4bfc-b446-9623e4fe7189'" />                         <attrcontainer>                             <attr type="string">                                 <name value="'name'" />                                 <value value="'wssmetadata'" />                             </attr>                             <attr type="uuid">                                 <name value="'scanid'" />                                 <value value="afe2e194-0ce7-4bfc-b446-9623e4fe7189" />                             </attr>                             <attr type="string">                                 <name value="'imagepath'" />                             </attr>                             <attr type="string">                                 <name value="'imagepathhd'" />                             </attr>                             <attr type="string">                                 <name value="'imagepaththumbnail'" />                             </attr>                             <attr type="string">                                 <name value="'imagepathgrey'" />                                 <value value="'images/afe2e194-0ce7-4bfc-b446-9623e4fe7189_grey.jpg'" />                             </attr>                             <attr type="string">                                 <name value="'imagepathgreyhd'" />                                 <value value="'images/afe2e194-0ce7-4bfc-b446-9623e4fe7189_grey_hd.jpg'" />                             </attr>                             <attr type="string">                                 <name value="'imagepathgreythumbnail'" />                                 <value value="'images/afe2e194-0ce7-4bfc-b446-9623e4fe7189_grey_thumbnail.jpg'" />                             </attr>                         </attrcontainer>                     </subcontainer>                 </attrcontainer>             </subcontainer>         </attrcontainer>     </companyname> 

i want change example 'images/afe2e194-0ce7-4bfc-b446-9623e4fe7189_grey_thumbnail.jpg' else, , write xml, main point don't want delete or change <unknown> sections.

i wrote code read nodes interested in , code can read them , extract data them, how write reset when have no information other nodes?

if necessary in in code, can read file follows.

string filecontent = null; using (streamreader streamreader = new streamreader(@"thefile.xml")) {     filecontent = streamreader.readtoend(); } xmldocument doc = new xmldocument(); doc.loadxml(filecontent); 

after doing desired modifications in code, can saved file.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -