I have some big logs/dumps with SOAP (1line without wrapping). For first I done some simple Select-string like that:
$where = "D:\log\Test\"
$what = Get-ChildItem $where -Filter "*.txt"
$regex= "(?=<\?xml).*(Envelope>)"
$Path="d:\Log\"
$Result = "D:\Log\wynik2.log"
$string = select-string -Path $what -Pattern $regex
$string
Result is like:
D:\log\Test\test1.txt:1:g .vI.Y....(A..P.......<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">some text1</soap:Body></soap:Envelope>
D:\log\Test\test1.txt:2:g .vJ.YiB..(...P....R..<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">some text2</soap:Body></soap:Envelope>
...
D:\log\Test\test1.txt:4000:g .vL.Yb...'...P.......<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">some text2</soap:Body></soap:Envelope>
How can I drop everything what is not part of my SOAP (example: D:\log\Test\test1.txt:4000:g .vL.Yb...'...P.......)