Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi,

I was wonfering how i could say, if a XML Child Node has a attribute within the node of a specific value say for example "Text". I have the following code, i just need help with adapting this to what i need

C#
foreach (XmlNode node in xdoc.ChildNodes)
            {
                if (node.Name == "Bookings")
                {
                    foreach (XmlNode node_of_node in node.ChildNodes)
                    {
                        if (node_of_node.Name == "Booking")
                        {
                            string TimeVariable = node_of_node["Time"].InnerText;


Im wanting to say is if the node of the node "Time" has a value within that child node of a specific string then take that node and output it to a messagebox.

I know how to output things to a messagebox i just need helping with above though with getting the value within a node forexample called "Time" please.
Posted
Updated 13-Dec-13 4:43am
v3

1 solution

Use the XmlNode.Attributes property[^] to find all the attributes for the current node.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900