I want to split a XML Like string to tokens in c# or sql.
for example
input string is like
<entry><AUTHOR>C. Qiao</AUTHOR> and <AUTHOR>R.Melhem</AUTHOR>, "<TITLE>Reducing Communication </TITLE>",<DATE>1995</DATE>. </entry>
and I want this output:
C AUTHOR
. AUTHOR
Qiao AUTHOR
and
R AUTHOR
. AUTHOR
Melhem AUTHOR
,
"
Reducing TITLE
Communication TITLE
"
,
1995 DATE
.
This is the first attempt on how to solve this problem, considering the following:
1. XML String will be valid (i.e. there’s not going to be any invalid chars between tags)
Like this:
2. Splitting will be done by space
' 'Will print out
EDIT:
Now, to split based on “.” and a space, the best idea is to use regex. Like this:
You can add more delimiters if you’d like. The following example will give you the following:
Edit2:
And here’s an example that works with your original string, it is most likely not the best approach, since it doesn’t have a correct ordering of tokens, but it should be pretty close:
This will print out the following: