You can convert the given OpenXmlElementto XElementusing the following code:
OpenXmlElement el = ...;
XElement xel = XElement.Parse(el.OuterXml);
To convert XElement to OpenXmlElement, try the following code:
XElement xe = ...;
using(StreamWriter sw = new StreamWriter(new MemoryStream()))
{
sw.Write(xe.ToString());
sw.Flush();
sw.BaseStream.Seek(0, SeekOrigin.Begin);
OpenXmlReader re = OpenXmlReader.Create(sw.BaseStream);
re.Read();
OpenXmlElement oxe = re.LoadCurrentElement();
re.Close();
}
Hope this helps.
source
share