How to pick specific tag values in XML data

sean

New Member
In my application I need to create a folder structure like "*C:\Laptop1\folder\" , "C:\Laptop2\folder*" on my local machine using the xml file provided. Now the XML file has the file names that I am after. My xml code:\[code\]<?xml version="1.0" encoding="utf-8" ?><Proj><MachineIP><Machine><Name>Laptop 1</Name><Path>C:\ZipFiles\Laptop1\folder\</Path></Machine><Machine><Name>Laptop 2</Name><Path>C:\ZipFiles\Laptop2\folder\</Path></Machine><Machine><Name>Laptop 3</Name><Path>C:\ZipFiles\Laptop2\folder\</Path></Machine><Machine><Name>Laptop 4</Name><Path>C:\ZipFiles\Laptop2\folder\</Path></Machine><Machine><Name>Laptop 5</Name><Path>C:\ZipFiles\Laptop2\folder\</Path></Machine><Machine><Name>Laptop 6</Name><Path>C:\ZipFiles\Laptop2\folder\</Path></Machine></MachineIP></Proj>\[/code\]All I am interested is to know how to fetch the Machine/Name/So far I am not knowing how to pick a particular tag. Anyone know how to pick each Name within the Machine Tag. I have a 300mb file to filter out.My approach is to fetch each Name within the Machine tag and store it in a string, later use the string to create the structure. But I am stuck please help...My source code so far:\[code\]//doc createdXmlDocument doc = new XmlDocument();//loading file:filePath = System.IO.Directory.GetCurrentDirectory();filePath = System.IO.Path.Combine(filePath + "\\", "MyConfig.xml");try{ doc.Load(filePath);}catch (Exception ex){ MessageBox.Show("Config File Missing: " + ex.Message, "Config File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Application.Exit();}//fetch data:String[] MachineName = XMLData("PROJ/MachineIP/Machine", "Name");String[] MachinePath = XMLData("PROJ/MachineIP/Machine", "Path");//function XMLData():string[] temp;XmlNodeList nodeList = doc.SelectNodes(MainNode);int i = 0;temp = new string[nodeList.Count];foreach (XmlNode node in nodeList){ temp.SetValue(node.SelectSingleNode(SubNode).InnerText, i); i++;}return temp; \[/code\]Thanks,HRG
 
Back
Top