Reputation: 3910
I have a line of HTML source code like:
<span class="price proPrice" itemprop="priceCurrency" content="USD">US $<span itemprop="lowPrice">9.76</span> - <span itemprop="highPrice">13.26</span> </span>
I wonder if the corresponding DOM tree should be:
< s p a n >
/ | | \
[US $] <span> [-] <span>
| |
[9.76] [13.26]
Where "[ ]" contains the "#text" nodes. The above code displays as US $9.76 - 13.26
I'm learning the DOM tree structure myself but I get kind of confused here. Also I'd like to know whether leaf nodes can only be text nodes or img nodes? Thanks a lot!
Upvotes: 0
Views: 69
Reputation: 108975
That looks about right (the attributes, and white space after the last inner <span>
would also appear).
Also I'd like to know whether leaf nodes can only be text nodes or img nodes?
Any node that does not contain another node, eg. a <br \>
will be a leaf node.
Upvotes: 1