Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 25, 2012 02:54 PM by Ramesh T
Apr 25, 2012 02:34 PM|LINK
I need to get the value of an attribute out of an xml. One of the nodes in my XML document is "comment" and this is how my xml looks like
"<LabMessage ><Accession LabRequestAccessionID=\"163693\" ReasonForReferral=\"\" ClinicalData=\"\" Comment=\"Specimen A) Autopsy//Formalin. External Case Number:A12-000005 Bill Type:Client/Hospital Ordering Physician:Carpenter, John Date Of Service:04/24/2012 Time Of Service:12:00 Body Site/Source:abc Sub Site:abc Blood - Green-Top(s):1 Blood - Purple-Top(s):1 Bone Marrow - Green-Top(s):1 Bone Marrow - Purple-Top(s):1 Clinical History/ICD-9 Codes(s):121 Diagnosis Under Consideration / Rule Out:Test Diagnosis and Rule out Treatment History:Test Treatment Cold Ischemic time up to 1 hour:No 10% neutral buffered formalin:Yes ER/PR Fixation Duration greater than 6 and less than 72 hours:Unknown Comments:Test comments\" CreatedDate=\"04/20/2012\".....</Accession></LabMessage>
and I am trying to get access the "Bill Type" in the "Bill Type:Client/Hospital" to get the text "Client/Hospital" in the Comment node.
How do I pull it out?
To get the Comment node value I can say something like
accessionNode.Attributes["Comment"] but trying to get the value of "Bill Type" which is Client/Hospital.
Can some one help me with this?
Thanks in advance!
Apr 25, 2012 02:50 PM|LINK
dim doc as new xmldocument
just some psuedo but it might work :)
Apr 25, 2012 02:54 PM|LINK
Try something like this
XDocument xDocument = XDocument.Load(@"Ur xml path");
var accession = from x in xDocument.Descendants("Accession")
where x.Attribute("LabRequestAccessionID").Value == "something" //if u wanna add filters
if(accession.Count() > 0)
var comment = accession.First().Attribute("Comment").Value;
//parse and extract 'Bill Type' from comment value(string)