Click here to Skip to main content
15,892,697 members
Articles / Web Development / ASP.NET
Article

Learning WordML Basics

Rate me:
Please Sign up or sign in to vote.
2.14/5 (5 votes)
18 Jul 20062 min read 30.9K   14  
Introduction to WordML

Introduction

Learning WORDML - Part 2
 
Now that we have come to know about WordML lets move a bit deep in understanding
 
Why WordML?
 
Obviously this must be the question while using any newer technology every time. Make repeated query and study why this newer technology is introduced, what made them to device a higher version and other stuffs. This exercise would give a deeper insight of the current technology and a way to understand the disadvantages and discomforts in the earlier ones. Again back to square one. Why WordML? Earlier versions on Word doesn't provide any option to save the Word in XML.Reading any particular data from a Word Document was a difficult task.It was converted to HTML, then after some operations it was converted to XML and then it was analyzed. Now with the facility of WordML analysis of Word Documents has become much much simpler.
 
Once the XML is in hand, we can really play around with XML and manipulate on the contents very easily.
 
What is WordML made of?
 
In the previous write-up there was a simple example of WordML, lets recollect it again
_______________________________________________________________________
<?xml version="1.0"?>
<w:wordDocument
   xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
 
<w:body>
      <w:p>
         <w:r>
            <w:t>Have a Great Day Ahead</w:t>
      </w:r>
   </w:p>
</w:body>
 
</w:wordDocument>
_______________________________________________________________________
 
The document is collection of Paragraphs (w:p)
The Paragraph is made up of Text Runs (w:r)
The Text Runs are made up of Text Pieces (w:t)
 
The xml document is ready. Save the above lines in SampleWordml.xml and save it. When you double click on the icon the file is opened in IE (by default). But suppose we wanted to view the same in Word while double clicking add a line of code
 
<?xml version="1.0"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
   xmlns:w="
http://schemas.microsoft.com/office/word/2003/wordml">
 
Once this change is made and saved, the icon itself changes and clicking on the icon directly opens in a Word.
 
What if not a perfect WordML?
 
Suppose there is some typo error or missed closing a tag in the WordML what happens when we try to open the same file in Word? Word doesn't automatically close the tag instead it gives an error on opening the doc. The line number and type of error can also be obtained
 
 
 
Sample image
A small error was made in <w:t> Tag. The Word dint open the same document and gave an error.
 
More in the next ...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --