Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open xml document extract style

Status
Not open for further replies.

deejayAr

Technical User
Mar 20, 2008
126
US
<w:p>.....<w:p>
<w:p w:rsidR="00C72E37" w:rsidRDefault="00A27CF8" w:rsidP="00A27CF8">
<w:pPr>
<w:pStyle w:val="Description"/>
</w:pPr>
<w:r w:rsidRPr="00686C21">
<w:rPr>
<w:rStyle w:val="Habit"/>
</w:rPr>
<w:t>Trees, shrubs, lianas or herbaceous vines</w:t>
</w:r>

<w:p w:rsidR="00C72E37" w:rsidRDefault="00A27CF8">
<w:pPr>
<w:ind w:right="19"/>
</w:pPr>
<w:r>
<w:rPr>
.......
</w:rPr>
</w:r>
<w:r w:rsidRPr="00A27CF8">
<w:rPr>
<w:rStyle w:val="Family"/>
</w:rPr>
<w:t>SAPINDACEAE</w:t>
</w:r>
<w:r>
<w:rPr>
......
</w:rPr>
</w:r>
</w:p>
<w:p>.....<w:p>
<w:p>.....<w:p>




I need to loop through every <w:p> of the document
First need to find out it’s child <w :pPr> has child <w:pStyle> that contain w:val and get its value and <w:t>Trees, shrubs, lianas or herbaceous vines</w:t>
Then look at <w:p>’s other <w:r> children and find out if it’s any of child has
<w:rStyle w:val="name"/> and get it’s value and <w:t>SAPINDACEAE</w:t> value

So the result in key value dictionary

Style=” Description” : Text = “ Description”
Style = “Habit” : Text= ” Trees, shrubs, lianas or herbaceous vines”
Style= “Family” : Text = “SAPINDACEAE”

I’m using openxml document xdoument I need to find it's every style and their content from every <w:p>
And their text value
If some you know better way then please help me

 
Hi deejay,

What technology do you want to use? XSLT? VB or C#, Java??

Tom Morrison
Hill Country Software
 
Read the XML document into a DOM representation

Once you have the XML document in the DOM model, the easiest way to find specific nodes is through XPath selection.

If you don't understand how you can create XPath expressions to select nodes, I would suggest an XPath tutorial, such as the one found on w3schools.


Tom Morrison
Hill Country Software
 
this one is using csharp and needs to iterate through nodes


thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top