If i was presented with a string, for example:
What would be the way of going about pulling out each thing in order to piece it back together for reason of creating a new element. What I'm trying to do is turn something like the string above into this:
Note that it could possibly be HTML or XHTML, with quotes or without quotes for the attributes, any range of styles for the elements, slashes added to the single quotes, and an unknown amount of rows. I understand this could be very complicated, but am curious if:
1. There is in fact an easy/shortcut way to do this.
2. If no for #1, then will I need to use fuzzy logic for every possible item?
3. What's the best way to strip out such items to separate them properly?
Thanks for any help.
_______________
_brian.
Code:
<tr id="rowId"><td align="left" style="background:#FF0000;">"say" Blah!</td>
<td valign=bottom>S0m3's M0r3's $tuff?</td></tr>
What would be the way of going about pulling out each thing in order to piece it back together for reason of creating a new element. What I'm trying to do is turn something like the string above into this:
Code:
var newtr = document.createElement('tr');
newtr.id = 'rowId';
var newtd1 = document.createElement('td');
newtd1.align = 'left';
newtd1.style.backgroundColor = '#FF0000';
newtd1.innerHTML = '"say" Blah!';
var newtd2 = document.createElement('td');
newtd2.valign = 'bottom';
newtd2.innerHTML = 'S0m3\'s M0r3\'s $tuff?';
newtr.appendChild(newtd1);
newtr.appendChild(newtd2);
Note that it could possibly be HTML or XHTML, with quotes or without quotes for the attributes, any range of styles for the elements, slashes added to the single quotes, and an unknown amount of rows. I understand this could be very complicated, but am curious if:
1. There is in fact an easy/shortcut way to do this.
2. If no for #1, then will I need to use fuzzy logic for every possible item?
3. What's the best way to strip out such items to separate them properly?
Thanks for any help.
_______________
_brian.