如果XM1子节点具有“String”的属性,则- 救命 [英] If A XMl Child Node Has A Attribute Of "String" - Help

查看:54
本文介绍了如果XM1子节点具有“String”的属性,则- 救命的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如果XML子节点在特定值的节点中具有属性,例如Text,我想知道我怎么说? 。我有以下代码,我只需要帮助将其调整到我需要的内容



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

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.

推荐答案

使用 XmlNode.Attributes property [ ^ ]查找当前节点的所有属性。
Use the XmlNode.Attributes property[^] to find all the attributes for the current node.


这篇关于如果XM1子节点具有“String”的属性,则- 救命的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆