[英]Check XML if element exists
我想檢查現有的 XML 文件的元素,如果它存在,我希望它使用以下命令關閉 window:
print ("<script>window.close();</script>");
我到底想要做的是,打開一個特定的.xml 文件,例如“www.xxxx.com/10/test.xml”,然后繼續打開 window 到 '/10/' 的增加值目錄,所以它一直打開 /11/、/12/、/13/。 . . 等等。 顯然,每個將要打開的 window 都有延遲,我想檢查是否存在特定元素。
例如,XML 文件中出現兩種類型的錯誤:
<?xml version="1.0" encoding="UTF-8"?>
<error><![CDATA[This is an error Message, No such thing exists]]></error>
和
<?xml version="1.0" encoding="UTF-8"?>
<msg2><![CDATA[ERROR MSG]]></msg2>
因為它不斷打開不同的目錄,...www.xxxx.com/22/test.xml,在每個打開的目錄上我想檢查<error>
和<msg2>
是否存在,如果存在,我希望它關閉window,如果不是,我只想抓取<list>
並顯示
For the past week, I've started using Javascript and JQuery I failed because of 'Same origin policy' (also back then it wasn't.xml file) then i went over PHP tried few stuff failed again, and found a way that您可以在 xml 中查看 html 文件(使用?xml=1)
如何才能做到這一點?
在 PHP 中,您可以使用( SimpleXML )非常簡單地完成此操作,如以下問題答案中所述。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.