Hello,
Maybe somebody could help me. I need a two methods.
The first should open a xml file and get all nodes with the given parameter ie.:
XML file (file.xml):
<Menu id="1" Name="myMenu">
<MenuItem Header="Header 1" Name="header1" />
<MenuItem Header="Header 2" Name="header2">
<MenuItem Header="subHeader 2.1" Name="header2_1">
<MenuItem Header="subsubHeader 2.1.1" Name="header2_1_1" />
</MenuItem>
</MenuItem>
<MenuItem Header="Header 3" Name="header3" />
</Menu>
So, now I need to get the values from the xml with a method like this:
public static List<string, string>ReadXML(string filename, string node, string[] attributes, bool searchSubNodes);
calling method example: ReadXMLValues("file.xml", "MenuItem", new string[] {"Header", "Name"}, true);
and this would return a list of two strings like:
"Header 1", "header1"
"Header 2", "header2"
"subHeader 2.1", "header2_1" <-- this should be in the list only if searchSubNodes is enabled!
"subsubHeader 2.1.1", "header2_1_1" <-- the same for this one!!!
"Header 3", "header3"
THIS was the reading part and now the writting part:
filename is the same like above file.xml. public static void WriteXML(string filename, string node, List attributes);
now lets say the file.xml has empty header attributes like this:
<Menu id="1" Name="myMenu">
<MenuItem Header="" Name="header1" />
<MenuItem Header="" Name="header2">
And I need to put values into the headers, the finall result should look like this:
<Menu id="1" Name="myMenu">
<MenuItem Header="Header 1" Name="header1" />
<MenuItem Header="Header 2" Name="header2">
Is something like this possible??? C# gurus and other people who knows how to do this PLEASE PLEASE help me! I don't know how to do it.
Best regards!