0

I got string, that contains usual characters and xml. Like this

General Information
********************************************* bla-bla-bla

<?xml version="1.0" encoding="utf-16"?><eventData><field key="SomeID">49ddd6f1-2fef-4cac-9eea-92df285370e7</field> <MyData>SomeData</MyData> </eventData>

How can get string, that contains only xml? Or even all after <?xml ? Thanks for any help

1 Answer 1

4

Use Select-String and regular expressions. This returns everything including and after <?xml:

$s = @"
General Information
********************************************* bla-bla-bla

<?xml version="1.0" encoding="utf-16"?><eventData>
<field key="SomeID">49ddd6f1-2fef-4cac-9eea-92df285370e7</field>
<MyData>SomeData</MyData> </eventData>
"@

$s | Select-String -Pattern "(?s)<\?xml.*" | % { $_.Matches.Value }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.