What I'm trying to do is create an XmlNode at a specific path if it doesn't exist.
My function looks like this:
public XmlElement getElement(string path)
{
XmlElement result = (XmlElement)document.SelectSingleNode(path);
if (result == null) {
// TODO: Create the specified path here
}
return result;
}
Is there any built-in function I can use to create the element at the specified path? The path might contain attributes like this /root/element[@id="5"]/subelement/item[@name="thing"]
.
Thanks in advance!