开发者

Parsing Google Stock XML

I've spent a silly amount of time trying to figure this out, but at this point it's driving me insane. I'm trying to parse the XML for Google's unofficial stock api like this: http://www.goo开发者_运维问答gle.com/ig/api?stock=GOOG

I've never dealt with XML that uses only attributes, so I don't know if that's what's making me completely useless at figuring this out. I'm pulling in the XML via a simple PHP snippet, then attempting to parse it using jQuery.parse().

<script>
    var xml = '<? echo get_url_contents('www.google.com/ig/api?stock=GOOG'); ?>',
        xmlDoc = $.parseXML( xml ),
        $xml = $( xmlDoc ),
        $title = $xml.find( "last" );

    /* append stock value to #goog */
    $( "#goog" ).append( $this.attr($title) );
</script>

Am I just completely on the wrong track here? Any guidance would be fantastic.


Here’s what that last line would look like:

$("#goog").text($title.attr("data"))

(Although I’m not sure why the variable holding the <last> element is called $title?)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜