我有日誌文件,我需要編寫從這個文件獲取所有xml的程序。 文件看起來像從原始文本文件中獲取所有XML?
text
text
xml
text
xml
text
etc
你能不能給我建議什麼是更好地使用正則表達式或其他什麼東西? 也許可以用dom4j來做到這一點?
如果我會嘗試使用正則表達式,我看到下一個問題,文本部分有<>
標籤。
更新1: XML實例
SOAP message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
here is body part of valid xml
</soapenv:Body>
</soapenv:Envelope>
text,text,text,text
symbols etc
SOAP message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
here is body part of valid xml
</soapenv:Body>
</soapenv:Envelope>
text,text,text,text
symbols etc
感謝。
^[A-ZA-Z] [A-ZA -z] {0,4} + [\ n] * $ –