3

I'm using the wiktionary api to get information from the wiktionary.org..

I'm getting the data in the json format and i'm able to parse it too...

but i want to remove some portion of data from the result (in fact, i need only some data), but i dont how to remove certain content from the result..

the code i'm using is

<script type="text/javascript" src="./jquery-1.4.3.min.js"></script>
<div id="wikiInfo">&nbsp; contents</div>
<script type="text/javascript">
$.getJSON('http://en.wiktionary.org/w/api.php?action=parse&page=acting&format=json&prop=text&callback=?',
function(json) {
$('#wikiInfo').html(json.parse.text.*);
$("#wikiInfo").find("a:not(.references a)").attr("href", function(){ 
            return "http://sample.com/" + $(this).attr("href");});
$("#wikiInfo").find("a").attr("target", "_blank");  }
);
</script>

the above code renders the data as in the following page..

http://englishore.com/parse-wiki.php

But i need to scrap the Pronunciation and Translations portion from the result..

how can i do that?

Jacob
  • 41,721
  • 6
  • 79
  • 81
Clewon
  • 75
  • 7

2 Answers2

2

Please do not forget to include license information. I created a full working example at https://gist.github.com/674522, feel free to reuse the code. Beside the wrong selector, already mentioned by lonesomeday, the modification of href attributes did not catch all cases, so I fixed it.

Jakob
  • 3,570
  • 3
  • 36
  • 49
  • I haven't worked out the example.. If it suits me then Which license information should i use? – Clewon Nov 15 '10 at 03:18
  • Just include a message that says, the content is from Wikipedia and licensed under CC-BY-SA, and a link to the original article. – Jakob Nov 17 '10 at 20:18
1

You are trying to use json.parse.text.* to access the relevant part of the object. This is not valid JS syntax -- you can't use * in an array property. You'll have to use array-style syntax instead:

$('#wikiInfo').html(json.parse.text['*']);
lonesomeday
  • 233,373
  • 50
  • 316
  • 318