c# - How to check for existence of an element with XElement? -
Information in this code Before I select it, I am trying to check the existence of the rdfs: range element. I do this to avoid the possible tap reference exception at runtime
Private Readonly XNamespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax- Ns # "; Private Redoni XNamespace rdfs = "http://www.w3.org/2000/01/rdf-schema#"; Private readonly exhibit otology; Public listing & lt; MetaProperty & gt; Metaportiques {Receive (Select the new Metapapti with P. Elements (RdF + "Property" in Otolology} {About = P. Feature (About "RDF +"). Value, Name = P. Element (RDFS + "Labels) ") Value, range = p.Elements (rdfs +" range "). Calculation () == 1? P.Element (rdfs +" range "). Attribute (Rdf +" resource "). Value: null}}. ToList ();}}
This is kind of annoying to me, what I really want to do is something like this:
p.HasElements ( Rdfs + "range")? Property (rdfs + "ray Value (rdf + "resource"). Value: Nil
Although there is no hashelment (string element name)
the method is not available.
I think that I can make a method extension to do this, but is I wondering if there is something already created or if there are other ways to do this?
is the only basic thing, but the neater
Returns (in Elephant by P. Elements (rdf + " Property ") XRa Select nge = p.Element (rdfs + "range") Select new metapoopy {about {= p. Specialty (about "RDF +"). Value, name = p. Element (rdfs + "label"). Value, Comment = P.Element (rdfs + "Comment"). Value, range uriy = xrange == tap? Zero: xRange.Attribute (rdf + "Resources"). Values}). ToList ();
Comments
Post a Comment