c# - Regex to replace " with " only if it's not in another " -


i'm converting an encoded xml document original format

string myxml = oldxml.replace("&lt;", "<").replace("&amp;", "&")                                                    .replace("&gt;", ">")                                                    .replace("&quot;", "\"")                                                    .replace("&apos;", "'"); 

it works fine. want exclude &quot; if in &quot;.

example:

original xml

//note title value <v:shape id="_x0000_i1025" title="a&quot; title &quot;b"> </v:shape> 

encoded xml

&lt;v:shape id=&quot;_x0000_i1025&quot; title=&quot;a&quot; title &quot;b&quot;&gt; &lt;/v:shape&gt; 

recovered xml after replace

//note title value <v:shape id="_x0000_i1025" title="a" title "b"> </v:shape> 

as can see inside &quot; shouldn't convert ". how can replace regex doesn't replace inside &quot;

thank you

turned out don't need recover encoded xml.

since nodelement.setattribute("myxmlattribute", myxml); encodes original xml @ first place, when read attribute value , assign string, c# recover original xml automatically.

string content = thenode.attributes["myxmlattribute"].value; 

i don't need replacing.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -