Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
AnswerRe: Find Year from text in C# Pin
Gerry Schmitz27-Apr-10 23:19
mveGerry Schmitz27-Apr-10 23:19 
Questionchange the image to the color.. Pin
@nisha 2n27-Apr-10 15:35
@nisha 2n27-Apr-10 15:35 
AnswerRe: change the image to the color.. Pin
Mycroft Holmes27-Apr-10 17:13
professionalMycroft Holmes27-Apr-10 17:13 
GeneralRe: change the image to the color.. Pin
@nisha 2n27-Apr-10 20:20
@nisha 2n27-Apr-10 20:20 
QuestionPC Crashed: Getting "Class Library Cannot be Started Directly" error Pin
boreland27-Apr-10 14:38
boreland27-Apr-10 14:38 
AnswerRe: PC Crashed: Getting "Class Library Cannot be Started Directly" error Pin
Luc Pattyn27-Apr-10 15:07
sitebuilderLuc Pattyn27-Apr-10 15:07 
QuestionDLL Decomplile Pin
Abdullah S. Abdelhay27-Apr-10 8:24
Abdullah S. Abdelhay27-Apr-10 8:24 
AnswerRe: DLL Decomplile Pin
Dimitri Witkowski27-Apr-10 8:31
Dimitri Witkowski27-Apr-10 8:31 
AnswerRe: DLL Decomplile Pin
Ian Shlasko27-Apr-10 8:32
Ian Shlasko27-Apr-10 8:32 
AnswerRe: DLL Decomplile Pin
Pete O'Hanlon27-Apr-10 22:36
mvePete O'Hanlon27-Apr-10 22:36 
AnswerRe: DLL Decomplile Pin
harold aptroot28-Apr-10 2:00
harold aptroot28-Apr-10 2:00 
QuestionReading & Modifying XML Data in C# Pin
GrgBalden27-Apr-10 6:53
GrgBalden27-Apr-10 6:53 
AnswerRe: Reading & Modifying XML Data in C# Pin
Dan Mos27-Apr-10 7:17
Dan Mos27-Apr-10 7:17 
GeneralRe: Reading & Modifying XML Data in C# Pin
GrgBalden27-Apr-10 23:33
GrgBalden27-Apr-10 23:33 
GeneralRe: Reading & Modifying XML Data in C# [modified] Pin
Dan Mos28-Apr-10 3:24
Dan Mos28-Apr-10 3:24 
GeneralRe: Reading & Modifying XML Data in C# Pin
GrgBalden28-Apr-10 4:43
GrgBalden28-Apr-10 4:43 
GeneralRe: Reading & Modifying XML Data in C# Pin
Dan Mos28-Apr-10 8:02
Dan Mos28-Apr-10 8:02 
here you go.

I created a dummy class that holds the Block name and the rec count:

C#
public class BlockCount
{
    private int count = 0;
    public int Count
    {
        get { return count; }
        set { count = value; }
    }

    private string block;
    public string Block
    {
        get { return block; }
        set { block = value; }
    }
}

private void button1_Click(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load("Abs.xml");

        //get the requestNodes
        XmlNodeList requests = doc.GetElementsByTagName("Request");

        if (requests != null && requests.Count > 0)
        {
            blocks = new List<BlockCount>();
            //now get the blocks nodes
            foreach (XmlNode nd in requests)
            {
                foreach (XmlNode blck in nd.ChildNodes)
                {
                    //create a new instance of the class
                    BlockCount c = new BlockCount();
                    //set the name of the block
                    c.Block = blck.Name;
                    foreach (XmlNode rec in blck.ChildNodes)
                    {
                        c.Count++;
                    }
                    blocks.Add(c);
                }
            }
        }
        //this is just for testing the results witch are fine by the way
        dataGridView1.DataSource = blocks;
    }
}


modified on Wednesday, April 28, 2010 2:11 PM

GeneralRe: Reading & Modifying XML Data in C# Pin
GrgBalden28-Apr-10 10:44
GrgBalden28-Apr-10 10:44 
QuestionCheckbox on the ColumnHeader [modified] Pin
Natural_Demon27-Apr-10 4:55
Natural_Demon27-Apr-10 4:55 
AnswerRe: Checkbox on the ColumnHeader [modified] Pin
Natural_Demon27-Apr-10 5:39
Natural_Demon27-Apr-10 5:39 
AnswerRe: Checkbox on the ColumnHeader Pin
Natural_Demon27-Apr-10 9:12
Natural_Demon27-Apr-10 9:12 
QuestionHow Secure are MDF DB Files? Pin
Caniac21727-Apr-10 2:21
Caniac21727-Apr-10 2:21 
AnswerRe: How Secure are MDF DB Files? Pin
Michel Godfroid27-Apr-10 3:35
Michel Godfroid27-Apr-10 3:35 
GeneralRe: How Secure are MDF DB Files? Pin
Caniac21727-Apr-10 4:23
Caniac21727-Apr-10 4:23 
QuestionMessage Removed Pin
27-Apr-10 2:17
Emmet_Brown27-Apr-10 2:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.