ICustomXmlPart.CustomXmlPartDocument Property
Provides access to an XML document contained in a custom XML part.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v19.1.Core.dll
Declaration
Property Value
Type | Description |
---|---|
XmlDocument | A System.Xml.XmlDocument object that is the XML document. |
Remarks
Use the CustomXmlPartDocument property to load XML into the custom xml part, read, modify, and remove XML in the document.
Example
This code snippet demonstrates how to access a custom XML part to get the XML document and modify data in that document.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheetcontrol-api-part-3-t231273
workbook.LoadDocument("Documents\\CustomXml.xlsx");
XmlDocument xmlDoc = workbook.CustomXmlParts[1].CustomXmlPartDocument;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
string xPathString = "//whitepaper/contact[firstname='Roger']/firstname";
XmlNodeList xmlNodes = xmlDoc.DocumentElement.SelectNodes(xPathString, nsmgr);
foreach (XmlNode node in xmlNodes) node.InnerText = "Stephen";
workbook.SaveDocument("Documents\\CustomXmlRogerStephen.xlsx");
workbook.Worksheets[0].Cells["A2"].Value = xmlDoc.FirstChild.FirstChild.FirstChild.InnerText;
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomXmlPartDocument property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.