0

I understand when the format is in such

<MyML>
  <test1>47.2727</test1>
  <test2>54.3421</test2>
</MyML>

I can use

 $(xmldata).find('MyML').each(function(){
 var currV = $(this).find('test1').text();
 var dateT =   ($(this).find('test2').text();

to get those two values.

But what if the xml format become this?

<MyML>
<test1 val="47.2727"/>
<test2 val="54.3421"/>
</MyML>

and attribute could me more than just two, perhaps test3, test4 or more what command should i use to get all values?

3
  • that's Javascript, not PHP. Do you want it in PHP? Or should it be retagged? Commented Dec 15, 2011 at 2:38
  • sorry its in Javascript, my mistakes Commented Dec 15, 2011 at 2:39
  • You should take off the PHP tag, too, since it's not dealing with it here. Commented Dec 15, 2011 at 2:43

1 Answer 1

1

Try

$(this).find('test1').attr('val');

etc...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.