2010-08-25 15 views

risposta

0

Suggerisco di utilizzare le espressioni regolari. Inizia da questo post here

Non ho visto un plugin jQuery che fa esattamente quello che vuoi, ma sono sicuro che puoi modificare alcune convalide esistenti.

+2

* cough * http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454# 1732454 – Mottie

4

È possibile utilizzare un parser DOM per verificare se il contenuto è XML.

Vedere here.


SNIPPET:

if (window.DOMParser) 
    { 
    parser=new DOMParser(); 
    xmlDoc=parser.parseFromString(text,"text/xml"); 
    } 
else // Internet Explorer 
    { 
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); 
    xmlDoc.async="false"; 
    xmlDoc.loadXML(text); 
    } 
+0

var error = $ (xmlDoc.documentElement) .find ('parsererror'). First(); if (errore) ... Qualcosa di simile ti dirà se c'è un errore e un errore non molto utile come 'error.text()' – ponchietto