我必須提取標籤的內容之間的內容,這裏是我有:獲取標籤
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">iVBORw0KGgoAAAANSUhEUgAAAU0AAAD6CAYAAAAlSBW9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhehP1lnB3H1a4P75Ely8zMzOyYHcccjsNOHNtx7IDtJCbJgtEwM4tG0kgzghnRaEgMI2aWLNlisMVMlgxa73Wv2tvJ85xz ...
</string>
,這裏是什麼,我想:
iVBORw0KGgoAAAANSUhEUgAAAU0AAAD6CAYAAAAlSBW9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhehP1lnB3H1a4P75Ely8zMzOyYHcccjsNOHNtx7IDtJCbJgtEwM4tG0kgzghnRaEgMI2aWLNlisMVMlgxa73Wv2tvJ85xz ...
我試着用這個正則表達式:
iframeContents.match(/<string[^>]*>(.*?)<\/string>/i);
,但我不斷收到字符串變量並沒有更多的XML之一:
<string xmlns="http://tempuri.org/">iVBORw0KGgoAAAANSUhEUgAAAU0AAAD6CAYAAAAlSBW9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhehP1lnB...
感覺就像它的時間來鏈接到最有名的答案在SO,再 - > http://stackoverflow.com/questions/1732348/regex-match- open-tags-except-xhtml-self-contained-tags – adeneo 2013-03-19 18:06:16
如果這是在瀏覽器中,爲什麼不讓瀏覽器爲[你]做這件事(http://stackoverflow.com/questions/649614/xml-parsing-of-一個變量串式的JavaScript)。如果它的nodejs使用[libary](https://github.com/polotek/libxmljs/wiki/Element) – user1937198 2013-03-19 18:12:36
感謝您的回覆。我使用mootools,我不知道.find的等價物。我在文檔中看不到任何東西 – 2013-03-19 18:20:23