I have a string variable. I want to convert it in WordprocessingML(kind of XML). I can convert if I have only string variable(static string) but everytime value of string variable is different. I have tried by didn't get any logical idea.
Example:
- Dim strData As String
- strData = "This is <b>Bold</b> Text. This is <i>Italic</i> Text"
WordprocessingML (kind of XML) conversation:
- <?xml version="1.0"?>
- <?mso-application progid="Word.Document"?>
- <w:wordDocument
- xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
- xml:space="preserve">
- <w:body>
- <w:p>
- <w:r>
- <w:t>This is </w:t>
- </w:r>
- <w:r>
- <w:rPr>
- <w:b/>
- </w:rPr>
- <w:t>Bold</w:t>
- </w:r>
- <w:r>
- <w:t>Text. This is </w:t>
- </w:r>
- <w:r>
- <w:rPr>
- <w:i w:val="on"/>
- </w:rPr>
- <w:t>Italic</w:t>
- </w:r>
- <w:r>
- <w:t>Text</w:t>
- </w:r>
- </w:p>
- </w:body>
- </w:wordDocument>
In my case, `strData` can be any string which can have HTML tags for formatting.
Ex:
- strData = "This <b>is Bold</b> Text. This is <i>Italic</i> Text"
- strData = "<b><i>This is Bold Text. This is Italic</b></i> Text"
- strData = "<b>This is Bold</b> Text."
- strData = "<b>This is Bold.</b>"
I have tried to use Replace function but it doesn't work in all cases.
Can anybody suggest me how to convert any string in this kind of format?