Reading only XML from a text file which contains text, binary, and XML data?
I have a text file (.txt) which has text data, binary data, and XML data all mixed together within it. I've googled around for a few minutes and cannot figure out how to only extract the XML from this text file. Can the good users of SO offer some suggestion?
I'm using C# 4.0.开发者_开发问答
Since I cannot simply load the text file into an XDocument, I've been messing with regex, but this approach is getting me no where.
First of all, file can't be text and binary simultaneously: if it contains binary data, it's binary file. But from your description seems like it's a text file with some binary data in text-encoded form.
If you know what root tag name is then use substring search to locate start and end of xml document, "cut" it, and then you can process it in any way you want.
精彩评论