J
jackwootton
Hello,
I register a mutation listener on a DIV element. When a node is
inserted to the DIV I use the event object passed to my listener to
retrieve the node inserted. It could look like this.
<span class="message">
<b>Name</b>
<p>Hello World!</p>
</span>
Currently I parse this XHTML fragment using various DOM methods such
as
hasChildNodes(), nextSibling, previousSibling, etc (you get the idea).
However it is possible that the XHTML fragment that is inserted may
change, for example once every 2 months. I have attempted to make my
JavaScript as loosely coupled with the XHTML fragment as possible, but
do not feel this goes far enough. I would like to have some kind of
document, perhaps DTD, that I can use with JavaScript to parse the
XHTML
fragment. Therefore if the node inserted is changed to, for example:
<div class="message">
<b>Name</b>
<span>Hello World!</span>
</div>
Then all I would have to do would be to change the DTD (or whatever)
to
reflect the new structure, and the program would parse it correctly.
I hope I have made sense, and someone can help.
Many thanks,
Jack
I register a mutation listener on a DIV element. When a node is
inserted to the DIV I use the event object passed to my listener to
retrieve the node inserted. It could look like this.
<span class="message">
<b>Name</b>
<p>Hello World!</p>
</span>
Currently I parse this XHTML fragment using various DOM methods such
as
hasChildNodes(), nextSibling, previousSibling, etc (you get the idea).
However it is possible that the XHTML fragment that is inserted may
change, for example once every 2 months. I have attempted to make my
JavaScript as loosely coupled with the XHTML fragment as possible, but
do not feel this goes far enough. I would like to have some kind of
document, perhaps DTD, that I can use with JavaScript to parse the
XHTML
fragment. Therefore if the node inserted is changed to, for example:
<div class="message">
<b>Name</b>
<span>Hello World!</span>
</div>
Then all I would have to do would be to change the DTD (or whatever)
to
reflect the new structure, and the program would parse it correctly.
I hope I have made sense, and someone can help.
Many thanks,
Jack