'Powershell_how to get a section id of HTML DOM?

I'm new to Powershell. I'm curretly trying to get the url of both "a href" and "img src" which are defined in specific section id(id="YY").

The code below is the sample of html

<div id="XX">
  <section id="AA">
  </section>
    # many sections here
  <section id="YY">
    <a href="https://XYZ.jpg">
      <img src = "https://ABC.jpg">
    </a>
  </section>
    # many sections here
</div>

I managed to get the nodes of "div id="XX" by $elements = $html.getElementById("XX").childNodes. However I'm not sure how to get the childNode which holds the target "section id="YY". Is there any way to get it or resources I can look up to?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source