0

I have the following html code:

<name>Username</name>
<kills>1</kills>
<ach_count>3</ach_count>

And on and on.....

I am looking for a code that extracts the value from <tag></tag> and puts them into variable.

I don't want to use HTML Agility Pack, don't ask why.Also XML is not an option for me.

I hope you understand what i am looking for. If you have further question, ask.

2
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by notacop
0

You can use jQuery for pulling data. It's fairly simple.

Here's an example using your code.

http://jsfiddle.net/yZPve/

name = $("name").text();
kills = $("kills").text();
ach_count = $("ach_count").text();

alert(name);
alert(kills);
alert(ach_count);

The alerts are just to show that the data is being pulled.

If you've never used jQuery before, you need to download the jQuery library or include them from the google hosted server into the head tags of your page. Here's the libraries that you can include from Google.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>

Hope this helps.

Edited by PcPro12

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.