Need help.
I have make simple program convert doc file to xml file using vb.net.
Dim app As Word.Application = New Word.Application
Dim doc As Word.Document = app.Documents.Open(txtFileName.Text)
Dim writer As New XmlTextWriter("product.xml", System.Text.Encoding.UTF8)
writer.WriteStartDocument(True)
writer.WriteStartElement("JUDGEMENT")
writer.Formatting = Formatting.Indented
For Each paragraph As Word.Paragraph In doc.Paragraphs
paragraph.Next()
writer.WriteStartElement("p")
If (paragraph.Range.Font.Bold) Then
writer.WriteStartElement("b")
writer.WriteString(paragraph.Range.Text.Trim)
writer.WriteString(paragraph.Range.Text)
writer.WriteEndElement()
Else
writer.WriteString(paragraph.Range.Text)
End If
writer.WriteEndElement()
Next
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
app.Quit()
The result will be something like this. Problem is bold tag is not at the bold font, it put at the end of sentences.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<JUDGEMENT>
<p>
<b>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</b>
</p>
<p>
<b>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</b>
</p>
</JUDGEMENT>
But I need a result like this
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<JUDGEMENT>
<p>
<b>Lorem Ipsum </b>is simply dummy text of the printing and typesetting industry.
</p>
<p>
<b>Lorem Ipsum </b>is simply dummy text of the printing and typesetting industry.
</p>
</JUDGEMENT>
What do I need to add or changes? Thanks guys.
Aucun commentaire:
Enregistrer un commentaire