1

I'm trying to use jquery to select the contents of a certain XML node:

var entry_text = $('entry_text').text();

and apply a regular expression to it, sort of like this one:

\<entry_text\>(?<url>.*?/&gt;)(?<text>.*?)\</entry_text\>

So that if this is the XML node entry_text:

<entry_text>&lt;img src=&quot;http://site.com/image.jpg&quot; width=&quot;431&quot; height=&quot;480&quot; /&gt;
    Lorem Ipsum dolor sit amet</entry_text>

I'll get something like this:

<entry_text>Lorem Ipsum dolor sit amet</entry_text>
<entry_image><img src="http://site.com/image.jpg" width="431" height="480"/>

Only I'm not sure what the right regex is, or how to apply it to my string. Any ideas?

2
  • Is this data you've acquired through an XmlHttpRequest? If so, why not use JSON? Commented Apr 10, 2011 at 14:24
  • this is an XML file I've dumped from a database which I'm trying to clean up so I can import the data into a new CMS. Commented Apr 10, 2011 at 17:51

1 Answer 1

1

You may check these useful pages:

http://bassistance.de/jquery-plugins/jquery-plugin-validation/

and this is also a great plugin for regx matching in jquery:

http://plugins.jquery.com/plugin-tags/regular-expression

Let me know if this helped you, thanks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.