Jump to content
MakeWebGames

Actually use xml with ajax


mikemastah

Recommended Posts

I was wondering how would I do something like this with ajax.

I have a variable (user input) 'uuc' and i want the value 'phe' returned

this is my xml file:

 

<aminoacids>

<mrnacodes>

<ID>2</ID>

<mrna>uuc</mrna>

<aminocode>phe</aminocode>

</mrnacodes>

<mrnacodes>

<ID>1</ID>

<mrna>uuu</mrna>

<aminocode>phe</aminocode>

</mrnacodes>

<mrnacodes>

<ID>3</ID>

<mrna>uua</mrna>

<aminocode>leu</aminocode>

</mrnacodes>

etc.....

</aminoacids>

Link to comment
Share on other sites

Re: Actually use xml with ajax

Most people I know use a javascript/ajax library that will take the xml and parse it for you, turning it into a javascript object.

You would then be able to access all those fields just like any other javascript object.

Link to comment
Share on other sites

Re: Actually use xml with ajax

JSON looks pretty hard :) so how would I do the parser thing?

the problem is that I do not have access to PHP, MySQL, etc. only javascript.

I could rewrite the xml file to

<aminoacids>

<uuc>

<aminocode>phe</aminocode>

</uuc>

<uuu>

<aminocode>phe</aminocode>

</uuu>

<uua>

<aminocode>leu</aminocode>

</uua>

etc...

</aminoacids>

would that be easier?

Link to comment
Share on other sites

Re: Actually use xml with ajax

eval in Javascript let you run a javascript script as it was a javascript code. So basically you feed your JSon to the eval and you get the object back.

I would suggest you to check some tutorials websites how to do those things.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...