Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    171
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi all,

    How do you import an XML file into Word?

    Each entry has a Name and a Summary text field.

    I want to be able to remove the tabs, but keep the structure. So I want to preserve those two field names as Heading levels or style names so I can process them afterwards, using Find+Replace.

    TIA

    - avi

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    Avi,

    First off, which version of Word are you working in?

    If you're working in a version prior to Word 2007, you could open a blank document and then use Insert > File to insert the content of the xml file, into the Word document.

    You could create custom paragraph styles for 'Name' and 'Summary', and then using Find/Replace, search for example for "<Name>" and in the replace field, just specify the 'Name' style. Do the same for 'Summary'.
    Then change the replace field to 'No formatting', and do a series of find/replaces to get rid of text like "<Name>" and "</Name>", as well as the extra tabs.

    This would leave you with just the text entries, each associated with an identifying style.

    Gary

  3. #3
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    171
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks for the response!

    Using Word 2003.

    Ok, I tried it. I see all the pink summary tabs.

    E.g.,

    <<summary Gets or sets the application. summary>>

    where
    <<summary is pink
    and summary>> is pink
    and "Gets or sets the application." is black.

    See attachment.

    I could not grab the summary tags by a Find. Maybe there is a special Find character or Find setting that I am suppsed to set?

    Thanks,

    - avi



    Quote Originally Posted by Gary Frieder View Post
    Avi,

    First off, which version of Word are you working in?

    If you're working in a version prior to Word 2007, you could open a blank document and then use Insert > File to insert the content of the xml file, into the Word document.

    You could create custom paragraph styles for 'Name' and 'Summary', and then using Find/Replace, search for example for "<Name>" and in the replace field, just specify the 'Name' style. Do the same for 'Summary'.
    Then change the replace field to 'No formatting', and do a series of find/replaces to get rid of text like "<Name>" and "</Name>", as well as the extra tabs.

    This would leave you with just the text entries, each associated with an identifying style.

    Gary
    Attached Images Attached Images

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    avi,

    Are you sure you're working in Word 2003? - those pink xml tags look like what you get in Word 2007.

    See attached shot for what I'm seeing in Word 2003.

    I'm not sure offhand how to do the equivalent in Word 2007, but will check once I can get over to a PC with 2007 on it.

    Gary
    Attached Images Attached Images

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    Just a followup:

    If you do an Insert > File of an XML file in Word 2007 (you may need to add the Insert > File command to the QAT), you get the result as illustrated below.

    Let me know which version of Word you're using and what commands you're using to import the XML, thanks.

    Gary
    Attached Images Attached Images

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    Yet another followup:

    You get the pink XML brackets (in both Word 2003 and Word 2007) if you do a direct File > Open on the XML file.

    I'm not versed in manipulating XML that's in an XML file that's directly opened in Word, but I wouldn't expect there to be many options to manipulate the file, because it is an XML file and needs to remain structured in a very specific way - what you're seeing when you directly open an XML file in Word is more of a visual representation of the data. It looks like you may be able to apply an XSLT to it to affect the view of the data, but I can't provide any guidance on that.

    In any case, if you do a File > Insert, you've then got the XML data in a regular Word document, and you can then transform it via Find/Replace.

    Gary

  7. #7
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    171
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I can also try Word 2007. I own that also.

    >> In any case, if you do a File > Insert,

    I assume you mean ' Insert > File ' :-)

    >> Let me know which version of Word you're using and what commands you're using to import the XML, thanks.

    I did use ' Insert > File ' - and got the pink tags.

    tnx

    avi

  8. #8
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    171
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ok, I just tried it with Word 2007. Insert > File of an XML file.
    Still get the pink tabs.

    Maybe there is another viewing mode I should be using?

    - avi



    Quote Originally Posted by Gary Frieder View Post
    Just a followup:

    If you do an Insert > File of an XML file in Word 2007 (you may need to add the Insert > File command to the QAT), you get the result as illustrated below.

    Let me know which version of Word you're using and what commands you're using to import the XML, thanks.

    Gary

  9. #9
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    Yep, I meant 'File > Insert', thanks. ;-)

    What happens if you try the following in Word 2007:

    Open new empty document.
    On the Insert tab, in the Text group, click on the down arrow to the right of 'Object', click on 'Text from file', navigate to your XML file, and click on insert.

    When I try it here, I get plain text with tabs, and not the pink XML markers.

    Gary

  10. #10
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,534
    Thanks
    3
    Thanked 147 Times in 140 Posts
    XML is essentially a database format stored in a flat ASCII file. If you open it with a text editor or with Word as Gary suggests then you can see everything in the file with no formatting. Editing this flat text is easy enough but you need to ensure that you don't break the xml so that it remains 'well formed".

    The way you have opened the file has parsed the data into its elements but you have not chosen a way to display the data. This is done by associating an XSL transformation with the xml data. This allows you to view the data lots of different ways. For example, one view might show only the assembly\name elements arranged in alphabetical order followed by the members\member\summary elements. Another view might show the members\member\summary elements as bulleted text under a heading. Without seeing the complete xml file or the schema on which it is based, we can only guess at how you might want to view the data.

    I think an easier way for you to view and edit your data is to use Microsoft Excel which will open the xml in a tabular way.

    Suggestion: Looking at your brief screen capture of the xml, the data doesn't look particularly well designed. The members element is independent of the assembly element although the names and line order does suggest a relationship. Positioning the tags adjacent to each other does not create a relationship in xml (although it does with words on a page). If this data is actually related then you need to structure it that way. For example, the following nests the members as part of an assembly.
    Code:
    <doc>
    	<assembly>
    		<name>ABC.BagsArranger</name>
    		<members>
    			<member>
    				<summary>Gets or sets the application</summary>
    			</member>
    			<member>
    				<summary>Occurs after the view changed its visibility state.</summary>
    			</member>
    		</members>
    	</assembly>
    </doc>
    A good place to start if you still want to pursue this XSL transformation of your XML data is this article by Bill Coan http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  11. #11
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    171
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi Andrew, Thanks for giving me your time on this.

    Tnx for your comment about the design of the XML.
    You made me read it. I did not write the XML. I am sorry about this but now I read for the first time and I see that Word had apparently trashed some of the clauses.
    So now I just loaded it into NotePad and here is the code below. In each clause 'member name' is the name of a member (property, method, or event) of a class, and 'summary' is a brief description of what the member does.

    I could now simply load it into Word as ascii text and do successive Find+Replaces to get just the 'member name' + 'summary', but I was wondering if there was an easy way to parse this so I get a nice table of something.

    >> I think an easier way for you to view and edit your data is to use Microsoft Excel which will open the xml in a tabular way.

    Just tried that. Thanks! I get an enormous table. That does it! I can move on from there.


    Great thanks,

    - avi

    Code:
    <?xml version="1.0"?>
    <doc>
        <assembly>
            <name>ABC.BagsArrangerUI</name>
        </assembly>
        <members>
            <member name="P:ABC.Applications.BagsArranger.IBaseComponent.Application">
                <summary>
                Gets or sets the application.
                </summary>
            </member>
            <member name="E:ABC.Applications.BagsArranger.Views.IView.IsVisibleChanged">
                <summary>
                Occures after the view changed its visibility state.
                </summary>
            </member>
            <member name="E:ABC.Applications.BagsArranger.Views.IView.IsActiveChanged">
                <summary>
                Occures after the view changed its active state.
                </summary>
            </member>
            <member name="P:ABC.Applications.BagsArranger.Views.IView.IsVisible">
                <summary>
                Gets or sets a value indicating whether the view is visible.
                </summary>
            </member>
            <member name="P:ABC.Applications.BagsArranger.Views.IView.IsActive">
                <summary>
                Gets or sets a value indicating whether the view is active.
                NOTE: In case the view is not active it means it will not be visible and the user
                will not be able to make it visible from the ToolBar.
                </summary>
            </member>
            <member>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •