开发者

Jquery | XML loading by name or id only

I'm new to Jquery and I'm trying add a function that will load the id or name of the xml only once. Here's an example, where I have "name" I would like to only load those sections into an div id, not an array. Thanks, I hope this makes sense.

<?xml version="1.0" encoding="utf-8" ?>
<newslinks>

    <news name="fs_img" imageurl="news/2011/01/w01/imgs/banner1_thumb.jpg">
        <url1>news/2011/01/w01/imgs/banner1.jpg</url1>
        <alt1>Headline 1</alt1>
        <date name="fs_date" >01/01/11</date>
        <headline name="fs_hl" >Headline 1 Story</headline>
        <url2 name="fs_hll" >#/url2>
        <headlinelink name="fs_hlls">Headline 1 Story Link</headlinelink>
    </news>

    <news imageurl="news/2011/01/w01/imgs/banner2_thumb.jpg">
        <url1>news/2011/01/w01/imgs/banner2.jpg</url1>
        <alt1>Headline 2</alt1>
        &开发者_JAVA百科lt;date>01/01/11</date>
        <headline>Headline 2 Story</headline>
        <url2>#</url2>
       <headlinelink>Headline 2 Story Link</headlinelink>
    </news> 




</newslinks>


Something like

var news = $("[name='fs_img']");

Untested but i think it should work.

or

    $("[name='fs_img']").each(function(){ 
      //do something with the element 
      //$(this)......
    });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜