title: Editing Sharepoint Online HTML content using Client Object Model
body: <p>We have a sharepoint online site with a good amount of pages that have href links to a shared in-house network server. Example: <strong>file://servername/sharedFolder</strong>  This way when the user clicks the href - it directs them to the location in the file explorer if using IE or Edge.</p>
  <p>Due to server maintenance - we needed to rename the server. So now &quot;servername&quot; is &quot;servername1&quot;. This messes up all the links on the sharepoint site.</p>
  <p>I need to iterate over all the pages on the sharepoint site, and fix the hrefs.</p>
  <p>I apologize im very new to sharepoint so maybe im missing something very simple.</p>
  <p>What i have right now is the following:</p>
  <pre><code>using (ClientContext ClientWebContext = new ClientContext(&quot;site&quot;))
          {
              ClientWebContext.Credentials = new SharePointOnlineCredentials(&quot;username&quot;, ss);
              Web web = ClientWebContext.Web;
              Microsoft.SharePoint.Client.File file = ClientWebContext.Web.GetFileByServerRelativeUrl(&quot;page&quot;);
              ClientWebContext.Load(web, w =&gt; w.Title, w =&gt; w.Description, w=&gt; w.Lists);
              ClientWebContext.Load(file, f =&gt; f.Length, f=&gt; f.ServerRelativeUrl, f=&gt; f.Name, f=&gt;f.);
              ClientResult&lt;System.IO.Stream&gt; str = file.OpenBinaryStream();
  
              ClientWebContext.ExecuteQuery();
              FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ClientWebContext, file.ServerRelativeUrl);using (FileStream filestream = new FileStream(&quot;C:&quot; + &quot;\\&quot; + file.Name, FileMode.Create))
              {
                  fileInfo.Stream.CopyTo(filestream);
              }
          }
  </code></pre>
  <p>The idea was to download the page - parse the html and update the hrefs, then write the page back out to the sharepoint server. But when i view the file that has been downloaded it doesnt contain any of the html that is actually on the page.</p>
  <p>If i go to a page, select &quot;edit&quot;, then select &quot;Edit Source&quot; I can view and edit all the html in raw format.</p>
  <p>I guess the question is - how do i get this html and how do i pro grammatically update it.</p>
  <p>EDIT:
  A typical sharepoint page contains a table, cells &amp; text inside of those cells. The text then contains links to the server I was talking about above. The sharepoint site is essentially being used as a wiki for new employees and a resource for existing employees to find information quickly. It doesnt contain many complex web parts and embedded code, mainly just a table, cells and text.</p>
  <p>Thanks,
  -John</p>