using FreeSWITCH.Native; SwitchXmlDocument document = new SwitchXmlDocument(); SwitchXmlNode rootNode = document.CreateNode("root"); SwitchXmlNode childNode = document.CreateNode("child"); childNode.InnerText = "hello world"; rootNode.AppendChild(childNode); document.Save("test.xml");
using FreeSWITCH.Native; SwitchXmlDocument document = new SwitchXmlDocument(); document.Load("test.xml"); SwitchXmlNode rootNode = document.DocumentElement; foreach (SwitchXmlNode node in rootNode.ChildNodes) { string text = node.InnerText; Console.WriteLine(text); }
using FreeSWITCH.Native; SwitchXmlDocument document = new SwitchXmlDocument(); document.Load("test.xml"); SwitchXmlNode rootNode = document.DocumentElement; foreach (SwitchXmlNode node in rootNode.ChildNodes) { if (node.InnerText == "hello world") { node.InnerText = "goodbye world"; break; } } document.Save("test.xml");In this example, we load the switch_xml document from the "test.xml" file, then iterate through the child nodes of the root node and find the one with the text value "hello world". We then change its text value to "goodbye world" and save the document back to the file. The package library for the FreeSWITCH.Native switch_xml library is "FreeSWITCH.Native".