Please support our C# advertiser: Programming Forums
Views: 2032 | Replies: 3
![]() |
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
hi ...
i have a query i have created an application in c# i have put this code in button
but it couldnt works
i wish i could display an XML file in TextBox or TreeView plz help me out ..
i have a query i have created an application in c# i have put this code in button
string strXmlPath = "";
XmlDocument doc = new XmlDocument();
strXmlPath = ("C:/App_Data/Document.xml");
DataSet ds = new DataSet();
XmlTextWriter writer = new XmlTextWriter(strXmlPath,System.Text.Encoding.UTF8);
writer.WriteStartElement("folder");
writer.WriteElementString("FolderName", "App_Data");
writer.WriteElementString("FolderPath", "C:/App_Data/Document.xml");
writer.WriteEndElement();
writer.WriteStartElement("folder2");
writer.WriteElementString("FolderName", "App_Data");
writer.WriteElementString("FolderPath", "C:/App_Data/Document.xml");
writer.WriteEndElement();
ds.WriteXml(@strXmlPath, System.Data.XmlWriteMode.WriteSchema);
writer.WriteElementString("FolderName", "App_Data");
writer.WriteElementString("FolderPath", "C/App_Data/Document.xml");
writer.WriteEndElement();
//XmlNode parentNode = doc.DocumentElement;
//XmlNode bookNode = doc.CreateNode(XmlNodeType.Element, "book", null);
//doc.AppendChild(bookNode);
//XmlAttribute attr = doc.CreateAttribute("space");
//attr.InnerText = "4";
//bookNode.Attributes.Append(attr);
// Flush
//DisplayCatalog();
writer.Close();
}i wish i could display an XML file in TextBox or TreeView plz help me out ..
Last edited by Tekmaven : Jul 28th, 2008 at 3:29 pm. Reason: Code tags
Hi Dear,
Here i have a suggestion for u, I am not sure if it will be useful in your case but still i am sharing. I was also wufering to open an xml file with proper formating then after googling i found that we can use the web browser control to open the xml files
I am sure that this will increase your knowledge as well.
Use the WebBorwser control and set it's navigate property it will show the file.
Be sure to pass it complete file name with directory info
such as:
"C:/App_Data/Document.xml"
Regards,
Here i have a suggestion for u, I am not sure if it will be useful in your case but still i am sharing. I was also wufering to open an xml file with proper formating then after googling i found that we can use the web browser control to open the xml files
I am sure that this will increase your knowledge as well.
Use the WebBorwser control and set it's navigate property it will show the file.
Be sure to pass it complete file name with directory info
such as:
"C:/App_Data/Document.xml"
Regards,
Thanks and Best of Lusk,
Farid ud din Masood
MS.c (CS)
University of Agriculture, Faisalabad
Farid ud din Masood
MS.c (CS)
University of Agriculture, Faisalabad
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Hi Dear,
Here i have a suggestion for u, I am not sure if it will be useful in your case but still i am sharing. I was also wufering to open an xml file with proper formating then after googling i found that we can use the web browser control to open the xml files
I am sure that this will increase your knowledge as well.
Use the WebBorwser control and set it's navigate property it will show the file.
Be sure to pass it complete file name with directory info
such as:
"C:/App_Data/Document.xml"
Regards,
thx Masood 4 sharing ur knowlege..bt it woudnt works.....!wht else should i do.?i realy cant figure out y it wont display in listBox or treeView. do u have any other idea..
thx Best Regards.
TC
•
•
Join Date: Nov 2006
Posts: 47
Reputation:
Rep Power: 3
Solved Threads: 1
To display an xml in tree view or listbox i would recommend loading it into the XmlDocument class. This way you already have a tree. Then you can jsut parse through it and add what ever fields you would like and skip whatever you done want.
If you want to create a xml document the xml writer is a good class but it does allow possibilities for alot of errors for example forgetting to close and elelemt.
you can instead make the xml file using the xml writer and make the document element.
close the file and load it into the XmlDocument.
now you can just create elements and attributes easily by
XmlElement element=XmlDoc.CreateElement("name");
and set teh inner text, attributes and such from there.
look at something like this
If you want to create a xml document the xml writer is a good class but it does allow possibilities for alot of errors for example forgetting to close and elelemt.
you can instead make the xml file using the xml writer and make the document element.
close the file and load it into the XmlDocument.
now you can just create elements and attributes easily by
XmlElement element=XmlDoc.CreateElement("name");
and set teh inner text, attributes and such from there.
look at something like this
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode