The Source Open XML Document - VB

[Table of Contents] [Next Topic]

Attached to this page is the source Open XML word document that contains the paragraphs styled as Code.

This blog is inactive.
New blog: EricWhite.com/blog

Blog TOCThe document looks like this:

Following is the XML for the main document part.  You can see the body of the document, the paragraphs (w:p) with their style information, text runs (w:r) that may have formatting information, and text pieces (w:t) that contain the actual text of the paragraph.  You can see the w:commentRangeStart and w:commentRangeEnd elements that indicate the position of the comment, along with the comment id.  There is other stuff in there, including elements that indicate proofing errors, etc.  We don't care about those.

The main document part of this document looks something like this:

<?xmlversion="1.0"encoding="UTF-8"standalone="yes"?>
<w:documentxmlns:ve="https://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:r="https://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:m="https://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp="https://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:w="https://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:wne="https://schemas.microsoft.com/office/word/2006/wordml">
<w:body>
<w:p>
<w:pPr>
<w:pStylew:val="Heading1"/>
</w:pPr>
<w:r>
<w:txml:space="preserve">Parsing </w:t>
</w:r>
<w:proofErrw:type="spellStart"/>
<w:r>
<w:t>WordprocessingML</w:t>
</w:r>
<w:proofErrw:type="spellEnd"/>
<w:r>
<w:txml:space="preserve"> with LINQ to XML</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t>The following example prints to the console.</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="Code"/>
</w:pPr>
<w:commentRangeStartw:id="0"/>
<w:proofErrw:type="gramStart"/>
<w:r>
<w:t>using</w:t>
</w:r>
<w:proofErrw:type="gramEnd"/>
<w:r>
<w:txml:space="preserve"> </w:t>
</w:r>
<w:commentRangeEndw:id="0"/>
<w:r>
<w:rPr>
<w:rStylew:val="CommentReference"/>
<w:rFontsw:asciiTheme="minorHAnsi"
w:hAnsiTheme="minorHAnsi"/>
</w:rPr>
<w:commentReferencew:id="0"/>
</w:r>
<w:r>
<w:t>System;</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="Code"/>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="Code"/>
</w:pPr>
<w:proofErrw:type="gramStart"/>
<w:r>
<w:t>class</w:t>
</w:r>
<w:proofErrw:type="gramEnd"/>
<w:r>
<w:txml:space="preserve"> Program {</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="Code"/>
</w:pPr>
<w:r>
<w:txml:space="preserve"> </w:t>
</w:r>
<w:proofErrw:type="gramStart"/>
<w:r>
<w:t>public</w:t>
</w:r>
<w:proofErrw:type="gramEnd"/>
<w:r>
<w:txml:space="preserve"> static void Main(string[] </w:t>
</w:r>
<w:proofErrw:type="spellStart"/>
<w:r>
<w:t>args</w:t>
</w:r>
<w:proofErrw:type="spellEnd"/>
<w:r>
<w:t>) {</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="Code"/>
</w:pPr>
<w:r>
<w:txml:space="preserve"> </w:t>
</w:r>
<w:proofErrw:type="spellStart"/>
<w:proofErrw:type="gramStart"/>
<w:r>
<w:t>Console.WriteLine</w:t>
</w:r>
<w:proofErrw:type="spellEnd"/>
<w:r>
<w:t>(</w:t>
</w:r>
<w:proofErrw:type="gramEnd"/>
<w:r>
<w:t>"Hello World");</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="Code"/>
</w:pPr>
<w:r>
<w:txml:space="preserve"> }</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="Code"/>
</w:pPr>
<w:r>
<w:t>}</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
&nbsp