c# - AvalonEdit : How to modify the xshd file to change elements atrribute -


i try modify xshd file change attribute foreground of element color programmatically in c#. tried used xmlatrribute have access to , change didnt work. how can change ? thats xshd file below

 <?xml version="1.0"?> <syntaxdefinition name="boo" extensions=".boo" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> <color name="string" foreground="red" /> <color name="comment" foreground="green" />  <!-- main ruleset. --> <ruleset> <span color="comment" begin="//" /> <span color="comment" multiline="true" begin="/\*" end="\*/" /> <span color="string">   <begin>'</begin>   <end>'</end>   <ruleset>     <!-- nested span escape sequences -->     <span begin="\\" end="." />   </ruleset> </span> <keywords fontweight="bold" foreground="green">   <word>if</word>   <word>ifend</word>   <word>declared</word> </keywords> <!-- digits --> <rule foreground="gray">     \b0[xx][0-9a-fa-f]+  # hex number     |    \b     (    \d+(\.[0-9]+)?   #number optional floating point     |    \.[0-9]+         #or starting floating point     )     ([ee][+-]?[0-9]+)? # optional exponent   </rule> <rule  foreground="blue">     \w*-\w*-*\w*   </rule> <rule foreground="pink">     (\w*=\w*)   </rule>  </ruleset> </syntaxdefinition> 

with linq try :

xdocument doc = xdocument.load("file.xml"); xnamespace ns = "http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"; var element = doc.descendants(ns + "color").first(x => x.attribute("name").value == "string"); element.setattributevalue("foreground", "valuecolor"); doc.save("file.xml"); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -