hi we all know how the infopath is working. when we give details in infopath form the data is stored as XML File. And when we open it the data from XML are merged with infopath form design(template).
I need to show the data which is present in XML with my own designed(template) form in the runtime. My question is how can i read the fields which is in Infopath Form(in .xml). Then only i can design my own fo开发者_Python百科rm in the runtime.
i dont know if i understood your question correctly, but if you want to display xml data in another form you have to transform the xml or at least include it as a datasource in your own designed form.
public void SaveXML(string filePath, string sourceXpath)
{
XPathNavigator myRoot = MainDataSource.CreateNavigator();
XPathNavigator node = myRoot.SelectSingleNode(sourceXpath, NamespaceManager);
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.Write(node.OuterXml.ToString());
sw.Flush();
sw.Close();
}
}
//usage: make sure you understand reading a bit about xpath first, and you will easily know what to put here in param2. you can right click on on any node in the datasource tree of your infopath and select "copy xpath" string to clipboard.
SaveXML(_AuditsFolder + "\\" + fname, "/my:AuditForm/my:Audit");
精彩评论