c# - Getting XML elements textboxes from search string -
i've got xml file has multiple entries, each looking this:
-<crq> <id>crq000000003314</id> <status>1</status> <summary>complete</summary> <service>server</service> <impact>3000</impact> <risk>2</risk> <urgency>4000</urgency> <class>4000</class> <environment>1000</environment> <trigger/> <triggerid>cp_00</triggerid> <coordinator>user name</coordinator> <desc>ticket description.</desc> </crq>
i have string in c# app matches id, eg crq000000003314. how able load xml , return elements underneath id (status summary etc) separate text boxes when string matched on event?
you can element using linq xml
this:
var xmldocument = xdocument.load("path"); var element = xmldocument .descendants("crq") .firstordefault(x => (string) x.element("id") == "crq000000003314"); if(element != null) { var status = (string)element.element("status"); // other values , display them in textbox }
Comments
Post a Comment