Highlight parents in xml string

Question :

Highlight parents in xml string,

Answer :

Say I have:

  

I want to add a class value to all the list items that are the parents of z. So, I want to modify y but not x.

Obviously, I can parse this into some kind of associative array and then recurse backwards. Any ideas how I can do it with just text processing (string replacing, regular expression, etc)?

Thanks!

That’s the answer Highlight parents in xml string, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Algorithm for joining e.g. an array of strings

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you