none
Import XML document into Word RRS feed

  • Question

  • Dear Collegs,

    I have one issue and hope that maybe somebody can help me.

    Namely, my problem is in that that can not figured out how to import one XML document to word.

    My goal is for example that if have one XML with this structure

    <CV>

    <NAME>Petter Jonson </NAME>

    <CITY>London</CITY>

    <Country>UK<Country>

    <Company>CompanyAAA<Company>

    </CV>

    When import(Merge) this XML with Microsoft Word I would like to get this result.

    POTENTIONAL EMPLOYEE CV

    Name : Petter Johnson

    City : London

    Country : UK

    Company : CompanyAAA

    Is possible on some way to do this mapping between XML file and Microsoft Word document.

     

    Thanks in advance.

    Thursday, July 1, 2010 4:07 PM

Answers

  • Hi Stomar

    Given Word 2007, I'd say you should first take a look at the concept of Content Controls and linking these to the elements of a Custom XML Part.

    Say you'd have a template for your document. The template would contain the text and the fields (content controls) you want to display the XML information in.

    You create a Custom XML Part in the document and link it to the content controls. It's important that this Custom XML Part (which is a standard XML file) declare a Namespace, as the content controls require a namespace.

    You can then remove the Custom XML Part, and add your XML as a replacement (the content controls will remember the XPath, even if it's not present in the document). Or you can leave the Custom XML Part and substitute the content of the various elements.

    Using Office OpenXML it would also be possible to replace or edit the Custom XML Part in the closed docx "package", without needing to automate Word.


    Cindy Meister, VSTO/Word MVP
    Friday, July 2, 2010 5:54 PM
    Moderator

All replies

  • Hi Stomar

    Which version of Word does this involve? What's availalbe "out of the box" depends very much on the version of Word...


    Cindy Meister, VSTO/Word MVP
    Friday, July 2, 2010 9:07 AM
    Moderator
  • Hi Cindy,

    We talk about Microsoft Word 2007.

    Thanks on your help.

    Regards,

    Friday, July 2, 2010 9:15 AM
  • Hi Stomar

    Given Word 2007, I'd say you should first take a look at the concept of Content Controls and linking these to the elements of a Custom XML Part.

    Say you'd have a template for your document. The template would contain the text and the fields (content controls) you want to display the XML information in.

    You create a Custom XML Part in the document and link it to the content controls. It's important that this Custom XML Part (which is a standard XML file) declare a Namespace, as the content controls require a namespace.

    You can then remove the Custom XML Part, and add your XML as a replacement (the content controls will remember the XPath, even if it's not present in the document). Or you can leave the Custom XML Part and substitute the content of the various elements.

    Using Office OpenXML it would also be possible to replace or edit the Custom XML Part in the closed docx "package", without needing to automate Word.


    Cindy Meister, VSTO/Word MVP
    Friday, July 2, 2010 5:54 PM
    Moderator