Wolfram API XML Help
So I'm a little new to XML, I mean I get the gist of most of it I'm just no expert. So I'm writing this program that when asked a question it goes to the Wolfram API and asks it there, then Wolfram prints out an XML code containing the answer. Here's an example:
Question: Who is the president?
The answer is in the <plaintext> area. So I'm wondering if there was a way, after imputing the answer that if XML had a way of just giving me the answer, like a code that would only display what is between the <plaintext> & </plaintext>?
<queryresult success="true" error="false" numpods="1" datatypes="City,Country,Leader,People,USState" timedout="" timedoutpods="" timing="1.096" parsetiming="0.191" parsetimedout="false" recalculate="" id="MSPa54631a4hg0e0c5496d8b000044bfi5giibia4e8i" auth="" host="http://www3.wolframalpha.com" server="31" related="http://www3.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa54641a4hg0e0c5496d8b00001hefhhf2fe5fbe3g&s=31" version="2.6">
<pod title="Result" scanner="Data" id="Result" position="200" error="false" numsubpods="1" primary="true">
<source url="http://www.wolframalpha.com/sources/LeaderDataSourceInformationNotes.html" text="Leader data"/>
<source url="http://www.wolframalpha.com/sources/PeopleDataSourceInformationNotes.html" text="People data"/>
Anyone have any clues or suggestions? Help is greatly appreciated.
The return that you are getting (what you posted in the [code] tags) is not good xml. It hangs up in the first line at related="..." It's the second equal sign in the url that is killing this. I'm not that familiar with Wolfram API, but the little I read said you can change what you get sent back by your request structure. You should look into that.
document.write(xmlDoc.getElementsByTagName("plaintext").childNodes.nodeValue + "<br>");