none
Unable to add SDK2 objects to XElement RRS feed

  • Question

  • I am trying to open an docx package in an XDocument object
    and insert to the document, SDK02 Elements

    but nothing happens when i do  ReplaceNodes(or RemoveNodes, AddFirst)

    should this be possible?
    How else whould you do this?(Without XML text in the code)

    thanks Yaniv

    Here is my code:

    using

     

    W = DocumentFormat.OpenXml.Wordprocessing;<br/>
    
     
    
    XDocument XDoc = XDocument.Load(XmlReader.Create(new StreamReader(pp.GetStream(FileMode.Open, FileAccess.Read)))); 
    
    XElement BookMarkNode = XDoc.XPathSelectElement("//w:bookmarkStart[@w:name='" + bookmarkName + "']", xmlNamespaceManager);
    
    if (BookMarkNode != null)  
    
    {
    
    	BookMarkNode.ReplaceNodes( 
    
    	W.Run(new W.Text() { Text = bookmarkValue }));
    
    	//Nothing!!!!
    
    	BookMarkNode.RemoveNodes();
    
    	BookMarkNode.AddFirst(new W.Run(new W.Text() { Text = bookmarkValue }));
    	//Still nothing!!!!
    
    
    	XDoc.Save(XmlWriter.Create(pp.GetStream(FileMode.Open, FileAccess.ReadWrite))); 
    
    	break; 
    
    }
    
    

     

     
    Monday, December 21, 2009 7:59 AM

All replies