This is .NET 2.0 project. First of all the xml i what to parse:
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<diagramer>
<PKTABLE_NAME>TECH_Y_Category</PKTABLE_NAME>
<FKTABLE_NAME>TECH_File</FKTABLE_NAME>
</diagramer>
<diagramer>
<PKTABLE_NAME>TECH_File</PKTABLE_NAME>
<FKTABLE_NAME>TECH_Version</FKTABLE_NAME>
</diagramer>
<diagramer>
<PKTABLE_NAME>TECH_Group</PKTABLE_NAME>
<FKTABLE_NAME>TECH_D_Group_File_Version</FKTABLE_NAME>
</diagramer>
<diagramer>
<PKTABLE_NAME>TECH_Layout</PKTABLE_NAME>
<FKTABLE_NAME>TECH_File</FKTABLE_NAME>
</diagramer>
<diagramer>
<PKTABLE_NAME>CK_List</PKTABLE_NAME>
<FKTABLE_NAME>CK_Vote</FKTABLE_NAME>
</diagramer>
<diagramer>
<PKTABLE_NAME>CK_List</PKTABLE_NAME>
<FKTABLE_NAME>CK_Score</FKTABLE_NAME>
</diagramer>
<diagramer>
<PKTABLE_NAME>TECH_Page</PKTABLE_NAME>
<FKTABLE_NAME>TECH_Page</FKTABLE_NAME>
</diagramer>
<diagramer>
<PKTABLE_NAME>CK_List</PKTABLE_NAME>
<FKTABLE_NAME>Comments</FKTABLE_NAME>
</diagramer>
</DocumentElement>
As you can see some PKTABLE_NAME values are the same.
Im looping through that xml using code below:
StringBuilder sb = new StringBuilder();
foreach (XmlNode items in diagramTables)
{
string pkTable = items["PKTABLE_NAME"].InnerText.Replace("_",@"\_");
string fkTable = items["FKTABLE_NAME"].InnerText.Replace("_",@"\_");
sb.Append(pkTable);
sb.Append(" got ");
sb.Append( fkTable + Environment.NewLine);
}
Its not exaclly what i want to achive. I want to have all values but only once (i dont want to repeat them). after all i want to write sometingingh like this from xml above:
- TECH_Y_Category got
TECH_File - TECH_File got TECH_Version
- TECH_Group got TECH_D_Group_File_Version
- TECH_Layout got TECH_File
- CK_List got CK_Vote | CK_Score | Comments
- TECH_Page got TECH_Page
I hope you understand what im trying to achieve.
EDIT.
Code from Morawski worked perfectly for me so problem is solved ;).
Something like: