Regular Expression

M

Matt Frame

I am trying to use a Regular Expression to split out a file which has
multiple xml documents included in it. I am trying to use the SplitResults
method with the expression of "<\?xml" as the key to split and it works but
the expression itself is consumed so it is not in the result. I tried the
non-consuming expression of "?:" in front but that did not seem to do
anything for me. I am probably misunderstanding how this works.

I am new to regular expressions and I may not be doing the above correctly.
I was wondering if anyone has done something similar to this and could help
me along.

Thanks,

Matt
 
M

MSFT

Hi Matt,

I think you may consider the classes in System.XML instead of regular
expression. For example, XMLDocument. With Regular Expression, you need
compose the syntax checker for your self. With XMLdocument, you only need
to load the XML file and access every nodes in it.

For a sample on XMLDocument, you may refer to:

HOW TO: Modify and Save XML with the XmlDocument Class in .NET Framework SDK
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q301233


Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
C

Cor

Hi Matt,
When the answer from Luke fits you, than I have as addition to his answer;
take while doing that a look at "pattern". That is in my opinion a kind of
same function as the Regular Expression.
Cor
 
M

Matt Frame

Luke,

I understand that would be a solution but I receive more than just XML files
with multiples documents that need to be split out before processing. I
used the XML question as I figured it would be the easiest as my other files
also have start expressions before each document. I will just keep pluggin
along to find a way to split the file up in some other way I just thought a
regular expression would be beneficial for my needs.

Thanks,

Matt
 
M

MSFT

Hi Matt,

Regular Expression is suitable when there are obvious separator in the
document, like "<?xml" in your case. And you may add the separator string
after split.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top