Reputation: 1
Code Example: I have a string pageContent as below:
<div class="ExternalClassB18B2CED421C4DBE9D35A9D59DB7749C">
<table id="layoutsTable" style="width:100%;">
<tbody>
<tr style="vertical-align:top;">
<td style="width:100%;">
<div class="ms-rte-layoutszone-outer" style="width:100%;">
<div class="ms-rte-layoutszone-inner" role="textbox" aria-haspopup="true" aria-autocomplete="both" aria-multiline="true">
<p>Test Page</p>
<table width="100%" class="ms-rteTable-default" cellspacing="0">
<tbody>
<tr>
<td class="ms-rteTable-default" style="width:33.33%;">?ID</td>
<td class="ms-rteTable-default" style="width:33.33%;">?Task Name</td>
<td class="ms-rteTable-default" style="width:33.33%;">?Status</td>
</tr>
<tr>
<td class="ms-rteTable-default">?1</td>
<td class="ms-rteTable-default">?Task.1</td>
<td class="ms-rteTable-default">?Completed</td>
</tr>
</tbody>
</table>
<p> </p>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<span id="layoutsData" style="display:none;">false,false,1</span>
</div>
Then I use method UpdatePageContent to update into OneNote I try to debug and know that it can't parse to OneNote XML schemas. I try a lot of of ways and can't find solutions for this case. Need Help !!!
Upvotes: 0
Views: 424
Reputation: 287
OneNote Object Model does support HTML, but you need to put it inside the HTMLBlock element. Simply wrap your HTML with this:
<?xml version="1.0" encoding="utf-8"?>
<one:Page ID="--yourpageid--" xmlns:one="http://schemas.microsoft.com/office/onenote/2010/onenote">
<one:Outline>
<one:OEChildren>
<one:HTMLBlock>
<one:Data>
<![CDATA[
html goes here
]]>
</one:Data>
</one:HTMLBlock>
</one:OEChildren>
</one:Outline>
</one:Page>
Upvotes: 1
Reputation: 6606
You have a bunch of HTML as your input, but the OneNote client add-in object model requires XML content formed in one of the OneNote XML schemae; it doesn't interpret HTML (The OneNote service's REST API on the other hand does).
You could either switch to using the server-side API, or go through some process in your add-in to take the HTML and convert it to OneNote markup.
Upvotes: 0