vb.net - Covert Doc to XML -


i have make simple program convert doc file xml file using vb.net.

dim app word.application = new word.application dim doc word.document = app.documents.open(txtfilename.text)  dim writer new xmltextwriter("product.xml", system.text.encoding.utf8) writer.writestartdocument(true) writer.writestartelement("judgement") writer.formatting = formatting.indented  each paragraph word.paragraph in doc.paragraphs     paragraph.next()     writer.writestartelement("p")      if (paragraph.range.font.bold)         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 this. problem bold tag not @ bold font, put @ end of sentences.

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <judgement>   <p>     <b>lorem ipsum is dummy text of printing , typesetting industry.</b>   </p>   <p>     <b>lorem ipsum is dummy text of printing , typesetting industry.</b>   </p> </judgement> 

but need result this

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <judgement>   <p>     <b>lorem ipsum </b>is dummy text of printing , typesetting industry.   </p>   <p>     <b>lorem ipsum </b>is dummy text of printing , typesetting industry.   </p> </judgement> 

what need add or changes?

it looks have end tag @ end of paragraph. try way:

if (paragraph.range.font.bold)     writer.writestartelement("b")     writer.writestring(paragraph.range.text.trim)     writer.writeendelement()      writer.writestring(paragraph.range.text)         else     writer.writestring(paragraph.range.text) end if 

Comments

Popular posts from this blog

python - Installing PyDev in eclipse is failed -

PHP OOP-based login system -

c# - Nested Internal Class with Readonly Hashtable throws Null ref exception.. on assignment -