本文介绍了从一个节点提取xml值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 < 预订 > < booking_parts > < quote > < quote_entry cet_id = amoount = 20 / > < quote_entry cet_id = B amoount = 40 / > < / quote > < ; / booking_parts > < / booking > 我想从这个xml获得20金额,任何想法?解决方案 好吧我再见 已成功检索到所需的XmlNode。剩下的就是从该节点检索所需的属性。 所以这样的事情: Dim bookAmoount = Book.Attributes( amoount)。 如果您感兴趣,可以使用以下内容简化代码: Dim bookAmoount = doc.SelectSingleNode( // quote / quote_entry [@ cet_id ='A'])。属性( amoount)。值 <booking><booking_parts><quote> <quote_entry cet_id="A" amoount="20" /><quote_entry cet_id="B" amoount="40" /></quote></booking_parts></booking>I want to get amount 20 from this xml, any idea? 解决方案 Hi, well I see you have successfully retrieved the desired XmlNode. All that is left for you is to retrieve the required attribute from that node.So something like this:Dim bookAmoount = Book.Attributes("amoount").ValueAlso just in case you're interested you can simplify your code with something like this:Dim bookAmoount = doc.SelectSingleNode("//quote/quote_entry[@cet_id='A']").Attributes("amoount").Value 这篇关于从一个节点提取xml值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-15 01:19