Parsing complex HTML



  • i have a code here,

    <div class="section">
       <h3 class="textHeading">About</h3>
       <div class="primaryContent">
          <div class="pairsColumns aboutPairs">
             <dl>
                <dt>Gender:</dt>
                <dd>Male</dd>
             </dl>
             <dl>
                <dt>Birthday:</dt>
                <dd>Oct 1, 1996 (Age: 23)</dd>
             </dl>
             <dl>
                <dt>Country Flag:</dt>
                <dd>
                   <img src="styles/flags/Peru.GIF">
                </dd>
             </dl>
             <dl>
                <dt>IGN:</dt>
                <dd>
                   Onizuka
                </dd>
             </dl>
             <dl>
                <dt>Level:</dt>
                <dd>
                   70
                </dd>
             </dl>
          </div>
       </div>
    </div>
    

    i want to parse "70" under "level:" and " Onizuka" under "IGN:"


  • Admin

    .pairsColumns.aboutPairs dl:nth-child(4) dd for Onizuka
    .pairsColumns.aboutPairs dl:nth-child(5) dd for 70
    I didn't test them so let me know if they don't work



  • @Ruri it woks for this code snippet. but lets say there are more columns like facebook, twitter so the capture is gonna mess up cause its counting child tags instead of targeting the specific column innerHTML like "IGN:" or "LEVEL:"



  • hmm, use regex


  • Admin

    @MadmanDev then you have to be very specific with the full path, starting from body until you get to the div that wraps all those data. Or use regex.


Log in to reply