1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
string wordmlNamespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
//Open the document as an Open XML package and extract the main document part.
WordprocessingDocument wordPackage = WordprocessingDocument.Open("C:\\test.docx", true);
MainDocumentPart part = wordPackage.MainDocumentPart;
NameTable nt = new NameTable();
XmlNamespaceManager nsManager = new XmlNamespaceManager(nt);
nsManager.AddNamespace("w", wordmlNamespace);
//Load the part's XML into an XmlDocument instance.
XmlDocument xmlDoc = new XmlDocument(nt);
xmlDoc.Load(part.GetStream());
/* Get node count */
XmlNodeList nodeList = xmlDoc.SelectNodes("//w:bookmarkStart", nsManager);
foreach (XmlNode myXMLNode in xmlDoc.SelectNodes("//w:bookmarkStart", nsManager))
{
c'est ici que je voudrais rajouter des données !!!
} |
Partager