使用 Excel VBA 比较 XML 输入解析列表中的最大数字
Set node = xmldoc.SelectNodes("//Attribute[@name='XSHIP_LOCATION']")
For Each n In node
result = n.Text
logmsg = "XSHIP_LOCATION: " & result
Call PrintLog(logmsg, logline)
Next n
对于 xml 中包含 name=XSHIP_LOCATION 的每一行,都会读取该属性的值。我如何比较从 XML 读取的结果列表并选择最大的数字?
结果 = 1, 2,1,3,5,4,1,2 的示例
我想从 XML 读取的输入列表中找到最大的数字,在本例中使用 .
有好心人可以帮助这个新手吗?谢谢
Set node = xmldoc.SelectNodes("//Attribute[@name='XSHIP_LOCATION']")
For Each n In node
result = n.Text
logmsg = "XSHIP_LOCATION: " & result
Call PrintLog(logmsg, logline)
Next n
For every line in xml that contains name=XSHIP_LOCATION, the value of that attribute will be read. How can i compare the list of results read from XML and pick the highest number?
Example of result = 1, 2,1,3,5,4,1,2
I would like to find the largest number from the list of inputs read from XML which is 5 in this case using .
Can anyone kind enough to help this newbie? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不添加第二个变量来捕获最大值,然后通过循环的每次迭代,将最大值与结果进行比较......因此
请注意,如果 n 不是数字,这将引发错误。
why not add a second variable to capture the maximum value, then each iteration through the loop, compare the maximum to the result.... as such
Note that if n is NOT a number, this will throw an error.