asp.net - I'm having trouble querying an XDocument using LINQ -


I am new to LINQ so that I gather, I have some syntax wrong. I have seen many examples online, but everyone seems to have their own style.

Here is the XML data I ask:

   & Lt; / Reaction & gt; & Lt; Reaction type = "object" id = "unknown" & gt; & Lt; Normal phenomenon = "position" privilege = channel = "sip / 452-000006fc" "call" calleridnum = "452" calleridname = "which" connectedlinenum = "430" connectedlinename = "device" accountcode = "" channelstate = "6" channelstatedesc = "Top" context = "macro-dial-one" extension = "s" priority = "37" seconds = "54" bridgedchannel = "br /> 430-000006fd" bridgeduniqueid = "1363822334.1829" uniqueid = "1363822334.1828" /> ; & Lt; / Reaction & gt; & Lt; Reaction type = "object" id = "unknown" & gt; & Lt; Normal phenomena = "position" privilege = channel = "sip / 430-000006fd" "call" calleridnum = "430" calleridname = "device" connectedlinenum = "452" connectedlinename = "which" account = "" state = "up" bradcchannel = "SIP / 452-000006 FC" Bridgedinidid = "1363822334.1828" unnatural = "1363822334.1829" /> & Lt; / Reaction & gt; & Lt; Reaction type = "object" id = "unknown" & gt; & Lt; General Event = "Status Completed" item = "2" /> & Lt; / Reaction & gt; & Lt; / Ajax-feedback & gt;   

And here I have so far:

  function ParseXML (string as xmlDocument) string xdoc as XDocument = XDocument.Load (new XmlNodeReader (Status XML) string as stringbilder = new stringbilder () Dim query = Xdock in Zedrick.Descendants ("generic") _ where generic. No specialty ("privilege") and general. Attribute ("privilege") value = "call" _ Select connectlinenum = generic.Attribute ("connectedlinenum"). ToString, _ calleridnum = generic.Attribute ("calleridnum"). Each I query parsed.Append (i.connectedlinenum) .Append (for ToString "") .Append (i.calleridnum) .Append (vbCrLf) Next Return Parsed.ToString End Function   

My guess is that I am misunderstood that my normal object is supposed to work, because in my code, in my reference, NullReferenceException gets when I referenced it Try to do

I'm not familiar with XML parsing, but none of the two you have privileges < / Code> not attribute, can this error occur?

In that case, what happens if you change from and to plus in the where section? This way, it will not evaluate the latter part of the statement if there is no privilege attribute.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -