I have a problem parsing the translated text from Microsoft Translator (Windows Azure). I followed the example from here, however, when I try to display the translated text in a VS XAML textbox, the output is: System.Data.Services.Client.QueryOperationResponse`1[Microsoft.Translation].
The submitted query is correct, but when I type it inside a browser, it does not return the translation on screen (it just shows the text "Translation" and the submitted time), but the page source gives an XML document, with correct translation inside a Text
tag.
This is my C# code:
var serviceRootUri = new Uri("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/");
var accountKey = "correct account key";
TranslatorContainer tc = new TranslatorContainer(serviceRootUri);
tc.Credentials = new NetworkCredential(accountKey, accountKey);
var translationQuery = tc.Translate(NameInput.Text, "en", "es");
textBox1.Text = translationQuery.Execute().ToString();
The page source (XML output):
> <feed xmlns:base="https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/Translate"
> xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
> xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
> xmlns="http://www.w3.org/2005/Atom">
> <title type="text" />
> <subtitle type="text">Microsoft Translator</subtitle>
> <id>https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/Translate?Text='Mundo'&To='en'&From='es'&$top=100</id>
> <rights type="text" />
> <updated>2012-04-18T10:02:42Z</updated>
> <link rel="self" href="https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/Translate?Text='Mundo'&To='en'&From='es'&$top=100"/>
> <entry>
> <id>https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/Translate?Text='Mundo'&To='en'&From='es'&$skip=0&$top=1</id>
> <title type="text">Translation</title>
> <updated>2012-04-18T10:02:42Z</updated>
> <link rel="self" href="https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/Translate?Text='Mundo'&To='en'&From='es'&$skip=0&$top=1"/>
> <content type="application/xml">
> <m:properties> <d:Text m:type="Edm.String">World</d:Text> </m:properties>
> </content>
> </entry>
> </feed>
I tried extracting the translated text from XML, following adapted code from here, here and here, as well as Linq, but it does not read from a file that is not saved. With the deprecated Bing translator, I managed to get the parsed text with the XElement.Parse(translatedText).Value
command, which is not working now. Is there a way to read from this document (parse from the page source), or any other way to get the translated text?