Read xprocessinginstruction using linq to xml

I have this much:

                        XDocument doc = XDocument.Load(existFile);

                        if (doc.FirstNode is XProcessingInstruction)
                            XProcessingInstruction PI = (XProcessingInstruction)doc.FirstNode;

And, ?PI.Data yields:

"format=\"850\" sender=\"AMAZON\" receiver=\"MYCLIENT\" ctrl=\"1\""

How do I read each of the individual attributes (format,sender,receiver,ctrl)?  Is there a method on PI.Data that will do this?  I haven't found one yet.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can try to use a regular expression:
                MatchCollection mm = Regex.Matches(PI.Data, @"(\w+)=\\""(.+?)\\""");
                foreach( Match m in mm )
                    Console.WriteLine( "Found {0} = {1}", m.Groups[1].Value, m.Groups[2].Value );

Open in new window

g_johnsonAuthor Commented:
I don't know much about Regex, but using the above mm returns nothing (the foreach is skipped); mm.Count() returns 0.

But, if what you are saying is that you just use string handling techniques, I can figure something else out.  I'm just wondering if there is some System.Linq.XML standard method to use to parse it out.
Probably there's no standard XML methods. Only an XElement can give access to its attributes, but a PI is not derived from XElement.

I strongly recommend you to get yourself familiar with the regular expressions. It's a very powerful technique to handle string data, could by used everywhere.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
g_johnsonAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.