简体   繁体   中英

How to append jQuery foreach variables to paragraph and table?

I am using jQuery Ajax function to parse a large XML file. I've gotten the hang of parsing but cannot figure out how to append the data to a paragraph or a table. I am trying to loop through the XML and display the player statistics and venue information in a paragraph for the venue and a table for the player statistics.. Here is the XML code sample. It is quite long but I thought it might be necessary for you all to see if needed.

<bbgame source="STAT CREW Basketball" version="4.15.03" generated="12/17/2013">
  <gametracker gameid="1288244"></gametracker>
  <venue gameid="GAME11"
           visid="MSU" visname="MISSOURI STATE"
           homeid="LOU" homename="LOUISVILLE"
           date="12/17/2013" location="KFC Yum! Center, Louisville, KY"
           time="9:05PM" attend="21335" schednote="" start="" end="" duration=""
           leaguegame="N" neutralgame="N" postseason="N">
    <officials text="Doug Sirmons, Rick Crawford, Tim Nestor"></officials>
    <rules prds="2" minutes="20" minutesot="5" fouls="5" qh="H"></rules>
  </venue>
  <status complete="Y" period="2" clock="00:00" running="F"></status>
  <team vh="V" id="MSU" name="MISSOURI STATE" record="8-2">
    <linescore line="24,36" score="60">
      <lineprd prd="1" score="24"></lineprd>
      <lineprd prd="2" score="36"></lineprd>
    </linescore>
    <totals>
      <stats fgm="22" fga="58" fgm3="4" fga3="15" ftm="12" fta="20" tp="60" blk="4" stl="5" ast="6" min="203" oreb="10" dreb="20" treb="30" pf="24" tf="0" to="13" deadball="3,1"
             fgpct="37.9" fg3pct="26.7" ftpct="60.0"></stats>
      <statsbyprd prd="1" fgm="9" fga="26" fgm3="1" fga3="5" ftm="5" fta="7" tp="24" blk="2" stl="2" ast="2" min="100" oreb="4" dreb="6" treb="10" pf="12" tf="0" to="7"></statsbyprd>
      <statsbyprd prd="2" fgm="13" fga="32" fgm3="3" fga3="10" ftm="7" fta="13" tp="36" blk="2" stl="3" ast="4" min="103" oreb="6" dreb="14" treb="20" pf="12" tf="0" to="6"></statsbyprd>
      <special vh="V" pts_to="10" pts_ch2="13" pts_paint="28" pts_fastb="0" pts_bench="26" ties="0" leads="1"
               poss_count="73" poss_time="1187" score_count="28" score_time="539" large_lead="2" large_lead_t="1st-19:40"></special>
    </totals>
    <player uni="01" code="01" name="Keith Pickens" checkname="PICKENS,KEITH" gp="1">
      <stats fgm="1" fga="3" fgm3="0" fga3="0" ftm="2" fta="3" tp="4" blk="1" stl="1" ast="0" min="15" oreb="0" dreb="2" treb="2" pf="2" tf="0" to="2" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="1" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="7" oreb="0" dreb="0" treb="0" pf="2" tf="0" to="1" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="2" fgm3="0" fga3="0" ftm="2" fta="3" tp="4" blk="1" stl="1" ast="0" min="8" oreb="0" dreb="2" treb="2" pf="0" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="02" code="02" name="Austin Ruder" checkname="RUDER,AUSTIN" gp="1" gs="1" pos="g">
      <stats fgm="2" fga="6" fgm3="1" fga3="5" ftm="0" fta="0" tp="5" blk="0" stl="0" ast="1" min="25" oreb="1" dreb="5" treb="6" pf="0" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="1" fgm3="0" fga3="1" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="12" oreb="0" dreb="2" treb="2" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="5" fgm3="1" fga3="4" ftm="0" fta="0" tp="5" blk="0" stl="0" ast="1" min="13" oreb="1" dreb="3" treb="4" pf="0" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="03" code="03" name="Michael Simpson" checkname="SIMPSON,MICHAEL" gp="1" oncourt="Y">
      <stats fgm="0" fga="1" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="0" treb="0" pf="1" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="0" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="1" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="0" treb="0" pf="1" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="05" code="05" name="Jarmar Gulley" checkname="GULLEY,JARMAR" gp="1" gs="1" pos="f">
      <stats fgm="5" fga="10" fgm3="0" fga3="2" ftm="4" fta="6" tp="14" blk="1" stl="0" ast="0" min="24" oreb="3" dreb="3" treb="6" pf="3" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="4" fga="6" fgm3="0" fga3="0" ftm="2" fta="2" tp="10" blk="1" stl="0" ast="0" min="14" oreb="2" dreb="0" treb="2" pf="1" tf="0" to="1" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="4" fgm3="0" fga3="2" ftm="2" fta="4" tp="4" blk="0" stl="0" ast="0" min="10" oreb="1" dreb="3" treb="4" pf="2" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="10" code="10" name="Ron Mvouika" checkname="MVOUIKA,RON" gp="1">
      <stats fgm="2" fga="4" fgm3="0" fga3="0" ftm="0" fta="3" tp="4" blk="0" stl="1" ast="2" min="13" oreb="2" dreb="1" treb="3" pf="5" tf="0" to="2" dq="1"></stats>
      <statsbyprd prd="1" fgm="1" fga="3" fgm3="0" fga3="0" ftm="0" fta="2" tp="2" blk="0" stl="0" ast="1" min="7" oreb="1" dreb="0" treb="1" pf="3" tf="0" to="1" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="1" fgm3="0" fga3="0" ftm="0" fta="1" tp="2" blk="0" stl="1" ast="1" min="6" oreb="1" dreb="1" treb="2" pf="2" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="11" code="11" name="Marcus Marshall" checkname="MARSHALL,MARCUS" gp="1" gs="1" pos="g">
      <stats fgm="2" fga="7" fgm3="1" fga3="3" ftm="3" fta="3" tp="8" blk="0" stl="0" ast="0" min="24" oreb="0" dreb="1" treb="1" pf="1" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="1" fga="3" fgm3="0" fga3="1" ftm="1" fta="1" tp="3" blk="0" stl="0" ast="0" min="14" oreb="0" dreb="0" treb="0" pf="1" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="4" fgm3="1" fga3="2" ftm="2" fta="2" tp="5" blk="0" stl="0" ast="0" min="10" oreb="0" dreb="1" treb="1" pf="0" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="12" code="12" name="Devon Thomas" checkname="THOMAS,DEVON" gp="1" oncourt="Y">
      <stats fgm="2" fga="5" fgm3="0" fga3="1" ftm="0" fta="0" tp="4" blk="0" stl="1" ast="1" min="18" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="1" ast="1" min="8" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="5" fgm3="0" fga3="1" ftm="0" fta="0" tp="4" blk="0" stl="0" ast="0" min="10" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="20" code="20" name="Gavin Thurman" checkname="THURMAN,GAVIN" gp="1" oncourt="Y">
      <stats fgm="2" fga="5" fgm3="0" fga3="1" ftm="0" fta="0" tp="4" blk="0" stl="1" ast="1" min="12" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="3" fgm3="0" fga3="1" ftm="0" fta="0" tp="0" blk="0" stl="1" ast="0" min="6" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="2" fgm3="0" fga3="0" ftm="0" fta="0" tp="4" blk="0" stl="0" ast="1" min="6" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="23" code="23" name="Dorrian Williams" checkname="WILLIAMS,DORRIAN" gp="1">
      <stats fgm="1" fga="5" fgm3="1" fga3="2" ftm="0" fta="0" tp="3" blk="0" stl="0" ast="1" min="15" oreb="0" dreb="1" treb="1" pf="1" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="1" fga="4" fgm3="1" fga3="2" ftm="0" fta="0" tp="3" blk="0" stl="0" ast="0" min="10" oreb="0" dreb="1" treb="1" pf="0" tf="0" to="1" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="1" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="1" min="5" oreb="0" dreb="0" treb="0" pf="1" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="24" code="24" name="Emmanuel Addo" checkname="ADDO,EMMANUEL" gp="1" gs="1" pos="f">
      <stats fgm="1" fga="2" fgm3="0" fga3="0" ftm="1" fta="2" tp="3" blk="0" stl="0" ast="0" min="11" oreb="1" dreb="2" treb="3" pf="5" tf="0" to="0" dq="1"></stats>
      <statsbyprd prd="1" fgm="1" fga="2" fgm3="0" fga3="0" ftm="0" fta="0" tp="2" blk="0" stl="0" ast="0" min="2" oreb="1" dreb="1" treb="2" pf="3" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="0" fgm3="0" fga3="0" ftm="1" fta="2" tp="1" blk="0" stl="0" ast="0" min="9" oreb="0" dreb="1" treb="1" pf="2" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="30" code="30" name="Nathan Scheer" checkname="SCHEER,NATHAN" gp="1" oncourt="Y">
      <stats fgm="1" fga="1" fgm3="1" fga3="1" ftm="0" fta="0" tp="3" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="0" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="1" fgm3="1" fga3="1" ftm="0" fta="0" tp="3" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="35" code="35" name="Bruce Marshall" checkname="MARSHALL,BRUCE" gp="1" oncourt="Y">
      <stats fgm="0" fga="1" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="1" treb="1" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="0" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="1" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="1" treb="1" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="42" code="42" name="Christian Kirk" checkname="KIRK,CHRISTIAN" gp="1">
      <stats fgm="1" fga="6" fgm3="0" fga3="0" ftm="2" fta="2" tp="4" blk="0" stl="0" ast="0" min="16" oreb="0" dreb="0" treb="0" pf="5" tf="0" to="3" dq="1"></stats>
      <statsbyprd prd="1" fgm="1" fga="3" fgm3="0" fga3="0" ftm="2" fta="2" tp="4" blk="0" stl="0" ast="0" min="12" oreb="0" dreb="0" treb="0" pf="2" tf="0" to="2" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="3" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="0" treb="0" pf="3" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="50" code="50" name="Tyler McCullough" checkname="MCCULLOUGH,TYLER" gp="1" gs="1" pos="c">
      <stats fgm="2" fga="2" fgm3="0" fga3="0" ftm="0" fta="1" tp="4" blk="2" stl="1" ast="0" min="18" oreb="1" dreb="4" treb="5" pf="1" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="1" stl="0" ast="0" min="8" oreb="0" dreb="2" treb="2" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="2" fgm3="0" fga3="0" ftm="0" fta="1" tp="4" blk="1" stl="1" ast="0" min="10" oreb="1" dreb="2" treb="3" pf="1" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="TM" code="TM" name="TEAM" checkname="TEAM" gp="1">
      <stats oreb="2" dreb="0" treb="2" pf="0" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="1" dq="0"></statsbyprd>
      <statsbyprd prd="2" oreb="2" dreb="0" treb="2" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
  </team>
  <team vh="H" id="LOU" name="LOUISVILLE" record="10-1">
    <linescore line="47,43" score="90">
      <lineprd prd="1" score="47"></lineprd>
      <lineprd prd="2" score="43"></lineprd>
    </linescore>
    <totals>
      <stats fgm="34" fga="66" fgm3="6" fga3="19" ftm="16" fta="30" tp="90" blk="7" stl="5" ast="14" min="202" oreb="20" dreb="31" treb="51" pf="18" tf="0" to="11" deadball="5,0"
             fgpct="51.5" fg3pct="31.6" ftpct="53.3"></stats>
      <statsbyprd prd="1" fgm="18" fga="33" fgm3="3" fga3="9" ftm="8" fta="15" tp="47" blk="4" stl="2" ast="7" min="100" oreb="13" dreb="14" treb="27" pf="7" tf="0" to="5"></statsbyprd>
      <statsbyprd prd="2" fgm="16" fga="33" fgm3="3" fga3="10" ftm="8" fta="15" tp="43" blk="3" stl="3" ast="7" min="102" oreb="7" dreb="17" treb="24" pf="11" tf="0" to="6"></statsbyprd>
      <special vh="H" pts_to="15" pts_ch2="21" pts_paint="46" pts_fastb="2" pts_bench="32" ties="2" leads="2"
               poss_count="72" poss_time="1210" score_count="44" score_time="680" large_lead="31" large_lead_t="2nd-02:05"></special>
    </totals>
    <player uni="00" code="00" name="ROZIER, Terry" checkname="ROZIER,TERRY" gp="1" gs="1" pos="g">
      <stats fgm="4" fga="8" fgm3="1" fga3="3" ftm="2" fta="3" tp="11" blk="1" stl="1" ast="1" min="24" oreb="1" dreb="7" treb="8" pf="1" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="3" fga="5" fgm3="0" fga3="1" ftm="2" fta="3" tp="8" blk="1" stl="1" ast="0" min="14" oreb="1" dreb="5" treb="6" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="3" fgm3="1" fga3="2" ftm="0" fta="0" tp="3" blk="0" stl="0" ast="1" min="10" oreb="0" dreb="2" treb="2" pf="1" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="01" code="01" name="GILL, Anton" checkname="GILL,ANTON" gp="1" oncourt="Y">
      <stats fgm="1" fga="1" fgm3="1" fga3="1" ftm="0" fta="2" tp="3" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="0" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="1" fgm3="1" fga3="1" ftm="0" fta="2" tp="3" blk="0" stl="0" ast="0" min="4" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="02" code="02" name="SMITH, Russ" checkname="SMITH,RUSS" gp="1" gs="1" pos="g" oncourt="Y">
      <stats fgm="4" fga="11" fgm3="0" fga3="3" ftm="3" fta="6" tp="11" blk="0" stl="2" ast="8" min="26" oreb="0" dreb="4" treb="4" pf="2" tf="0" to="4" dq="0"></stats>
      <statsbyprd prd="1" fgm="2" fga="4" fgm3="0" fga3="1" ftm="2" fta="4" tp="6" blk="0" stl="1" ast="4" min="14" oreb="0" dreb="3" treb="3" pf="0" tf="0" to="1" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="7" fgm3="0" fga3="2" ftm="1" fta="2" tp="5" blk="0" stl="1" ast="4" min="12" oreb="0" dreb="1" treb="1" pf="2" tf="0" to="3" dq="0"></statsbyprd>
    </player>
    <player uni="03" code="03" name="JONES, Chris" checkname="JONES,CHRIS" gp="1">
      <stats fgm="3" fga="9" fgm3="1" fga3="3" ftm="2" fta="2" tp="9" blk="1" stl="0" ast="1" min="20" oreb="0" dreb="2" treb="2" pf="3" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="2" fga="7" fgm3="1" fga3="3" ftm="0" fta="0" tp="5" blk="1" stl="0" ast="1" min="13" oreb="0" dreb="1" treb="1" pf="2" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="2" fgm3="0" fga3="0" ftm="2" fta="2" tp="4" blk="0" stl="0" ast="0" min="7" oreb="0" dreb="1" treb="1" pf="1" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="04" code="04" name="AVARE, Dillon" checkname="AVARE,DILLON" gp="0"></player>
    <player uni="05" code="05" name="WARE, Kevin" checkname="WARE,KEVIN" gp="1">
      <stats fgm="2" fga="3" fgm3="0" fga3="0" ftm="0" fta="0" tp="4" blk="0" stl="0" ast="0" min="5" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="0" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="3" fgm3="0" fga3="0" ftm="0" fta="0" tp="4" blk="0" stl="0" ast="0" min="5" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="11" code="11" name="HANCOCK, Luke" checkname="HANCOCK,LUKE" gp="1">
      <stats fgm="1" fga="4" fgm3="0" fga3="2" ftm="0" fta="0" tp="2" blk="1" stl="0" ast="1" min="22" oreb="1" dreb="0" treb="1" pf="1" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="3" fgm3="0" fga3="2" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="12" oreb="1" dreb="0" treb="1" pf="1" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="1" fgm3="0" fga3="0" ftm="0" fta="0" tp="2" blk="1" stl="0" ast="1" min="10" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="12" code="12" name="MATHIANG, Mangok" checkname="MATHIANG,MANGOK" gp="1" gs="1" pos="c" oncourt="Y">
      <stats fgm="4" fga="6" fgm3="0" fga3="0" ftm="0" fta="0" tp="8" blk="2" stl="0" ast="0" min="20" oreb="6" dreb="3" treb="9" pf="2" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="2" fga="3" fgm3="0" fga3="0" ftm="0" fta="0" tp="4" blk="1" stl="0" ast="0" min="10" oreb="4" dreb="1" treb="5" pf="1" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="3" fgm3="0" fga3="0" ftm="0" fta="0" tp="4" blk="1" stl="0" ast="0" min="10" oreb="2" dreb="2" treb="4" pf="1" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="15" code="15" name="HENDERSON, Tim" checkname="HENDERSON,TIM" gp="1" oncourt="Y">
      <stats fgm="0" fga="1" fgm3="0" fga3="1" ftm="2" fta="2" tp="2" blk="0" stl="1" ast="0" min="6" oreb="0" dreb="1" treb="1" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="0" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="1" fgm3="0" fga3="1" ftm="2" fta="2" tp="2" blk="0" stl="1" ast="0" min="6" oreb="0" dreb="1" treb="1" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="20" code="20" name="BLACKSHEAR, Wayne" checkname="BLACKSHEAR,WAYNE" gp="1" gs="1" pos="f">
      <stats fgm="4" fga="9" fgm3="3" fga3="6" ftm="0" fta="0" tp="11" blk="0" stl="0" ast="1" min="15" oreb="1" dreb="3" treb="4" pf="3" tf="0" to="2" dq="0"></stats>
      <statsbyprd prd="1" fgm="2" fga="3" fgm3="2" fga3="2" ftm="0" fta="0" tp="6" blk="0" stl="0" ast="0" min="8" oreb="1" dreb="1" treb="2" pf="1" tf="0" to="2" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="2" fga="6" fgm3="1" fga3="4" ftm="0" fta="0" tp="5" blk="0" stl="0" ast="1" min="7" oreb="0" dreb="2" treb="2" pf="2" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="21" code="21" name="BEHANAN, Chane" checkname="BEHANAN,CHANE" gp="1">
      <stats fgm="3" fga="4" fgm3="0" fga3="0" ftm="2" fta="4" tp="8" blk="0" stl="1" ast="1" min="17" oreb="2" dreb="4" treb="6" pf="2" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="2" fga="2" fgm3="0" fga3="0" ftm="1" fta="2" tp="5" blk="0" stl="0" ast="1" min="8" oreb="2" dreb="1" treb="3" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="1" fga="2" fgm3="0" fga3="0" ftm="1" fta="2" tp="3" blk="0" stl="1" ast="0" min="9" oreb="0" dreb="3" treb="3" pf="2" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="22" code="22" name="AGAU, Akoy" checkname="AGAU,AKOY" gp="1" oncourt="Y">
      <stats fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="6" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="1" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="5" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="23" code="23" name="LEVITCH, David" checkname="LEVITCH,DAVID" gp="0"></player>
    <player uni="24" code="24" name="HARRELL, Montrezl" checkname="HARRELL,MONTREZL" gp="1" gs="1" pos="f">
      <stats fgm="6" fga="7" fgm3="0" fga3="0" ftm="5" fta="11" tp="17" blk="2" stl="0" ast="0" min="26" oreb="4" dreb="4" treb="8" pf="1" tf="0" to="2" dq="0"></stats>
      <statsbyprd prd="1" fgm="3" fga="3" fgm3="0" fga3="0" ftm="3" fta="6" tp="9" blk="1" stl="0" ast="0" min="15" oreb="2" dreb="1" treb="3" pf="0" tf="0" to="2" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="3" fga="4" fgm3="0" fga3="0" ftm="2" fta="5" tp="8" blk="1" stl="0" ast="0" min="11" oreb="2" dreb="3" treb="5" pf="1" tf="0" to="0" dq="0"></statsbyprd>
    </player>
    <player uni="44" code="44" name="VAN TREESE, Stephan" checkname="VAN TREESE,STEPHAN" gp="1">
      <stats fgm="2" fga="3" fgm3="0" fga3="0" ftm="0" fta="0" tp="4" blk="0" stl="0" ast="1" min="11" oreb="5" dreb="3" treb="8" pf="3" tf="0" to="1" dq="0"></stats>
      <statsbyprd prd="1" fgm="2" fga="3" fgm3="0" fga3="0" ftm="0" fta="0" tp="4" blk="0" stl="0" ast="1" min="5" oreb="2" dreb="1" treb="3" pf="2" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" fgm="0" fga="0" fgm3="0" fga3="0" ftm="0" fta="0" tp="0" blk="0" stl="0" ast="0" min="6" oreb="3" dreb="2" treb="5" pf="1" tf="0" to="1" dq="0"></statsbyprd>
    </player>
    <player uni="TM" code="TM" name="TEAM" checkname="TEAM" gp="1">
      <stats oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></stats>
      <statsbyprd prd="1" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
      <statsbyprd prd="2" oreb="0" dreb="0" treb="0" pf="0" tf="0" to="0" dq="0"></statsbyprd>
    </player>
  </team>

I have read through some examples but I am having trouble figure out how to append this information to a paragraph and a table. jQuery

$(document).ready(function () { 
$.ajax({
type: "GET",
url: "lou.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('venue').each(function() {
    var home_name = $(this).attr('homename'); 
    $(".home_name").append(home_name);
    var away_name = $(this).attr('visname');
    $(".home_name").append(away_name);
    var game_date = $(this).attr('date');
    $(".home_name").append(game_date);
    var game_time = $(this).attr('time');
    $(".home_name").append(game_time);
$(xml).find('team[vh="H"]').each(function() {
    var name = $(this).find('player').attr('checkname');
    console.log(name);
});
});
}
});
});

HTML

<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<body>
    <table>
    <tr>
        <th>Player</th>
        <th>PTS</th>
        <th>3PM</th>
        <th>REB</th>
        <th>AST</th>
        <th>STL</th>
        <th>PF</th>
    </tr>
    <tr>
    <td> </td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
</tr>
</table>
</body>
</html>

Any help would be wonderful! I've been digging through examples and I'm just having a hard time figuring out how to do this.

Create the markup in the loops, and change the DOM once

$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "lou.xml",
        dataType: "xml",
        success: function (xml) {
            var container = $([]);
            $(xml).find('venue').each(function () {
                var tr  = $('<tr />'),
                    td1 = $('<td />', {text : $(this).attr('homename') }),
                    td2 = $('<td />', {text : $(this).attr('visname') }),
                    td3 = $('<td />', {text : $(this).attr('date') }),
                    td4 = $('<td />', {text : $(this).attr('time') }),
                    td  = $('<td />'),
                    tr2 = $('<tr />');

                $(xml).find('team[vh="H"]').each(function () {
                    var td5 = $('<td />', {text : $(this).find('player').attr('checkname') });
                    tr2.append(td5);
                });

                container = container.add( tr.append(td1, td2, td3, td4, td.append(tr2)) );
            });
            $('table tbody').append(container);
        }
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM