Jump to content

Recommended Posts

Posted

Boa tarde pessoal

Preciso ler um arquivo xml,online ... (um link do yahoo, um webservice com cotações de moedas)

e passar para uma textbox o valor do Dólar .

http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote

mas realmente eu não sei trabalhar com xml ....

Por exemplo na imagem que anexo à este post , tem um campo marcado : USD/VND como eu posso fazer para pegar o valor "PRICE " logo abaixo dele?

dsdsd56D8LMXA23.png

Posted (edited)

Provavelmente dá para optimizar a parte do xpath, mas pode ser algo deste tipo:

Dim xmlDoc As XmlDocument = New XmlDocument()
xmlDoc.Load("http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote")
For Each node As XmlNode In xmlDoc.DocumentElement.SelectNodes("//resource")
If node.SelectSingleNode("field[@name='name']").InnerText = "USD/MOP" Then
	MessageBox.Show(node.SelectSingleNode("field[@name='price']").InnerText)
	Exit For
End If
Next
Edited by nelsonr
  • Vote 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.