Parsing XHTML from mutation event

J

jackwootton

Hello ,

I posted a similar question a while ago here (http://groups.google.com/
group/comp.lang.javascript/browse_thread/thread/
eaa3a71a8c469195/90002ee2f13ef8c1).

However I feel this question is sufficiently different to warrant a
new discussion.

I create a listener for nodeInserted and nodeRemoved mutation events.
In that listener I use the event object to reference the node that was
inserted. Typically it looks like this (although it can differ by
being fewer lines):

<span chatdir="1">
<div class="msg">
<div>
<b style="margin-left: 3px;">XchatTest: </b>
<span chatindex="a3">Hello World!</span>
</div>
</div>
</span>

I need to parse this information and store it in an appropriate data
structure. I have created the data structure, but am not sure on the
best method of accessing the information I require, such as: chatindex
attribute of a span tag, chatdir attribute of the span tag, content of
the b tag, etc etc.

Ideally I would like to use XPath since it seems a clean elegant
method of accessing XML style information. Alternatively, should I
just use the DOM methods of childNode, getAttribute, etc?

Many thanks,

Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,103
Latest member
VinaykumarnNevatia
Top