How to check if an element exists in a given element before trying to add it?
Background . I have XDocument Xone that contains a child Flowers, which subsequently contains a series of elements, each of which is called Flower. Each Floweralready has 2 children, and I would like to add a third element with a name Price. However, I want to check and make sure that the element Flowerdoes not yet have an element for Price. How should I do it? Do I even need to check?
XDocument
X
Flowers
Flower
Price
XElement HasElements, , , - .
XElement
HasElements
...
XNamespace ns = "http://mynamespace.com"; bool hasPrice = flowerElement.Element(ns + "Price") == null;
.., , . , .
. - XML , Namespace.None ns.
Namespace.None
ns
Source: https://habr.com/ru/post/1730642/More articles:Deploying a QT application on OS X and Linux - qtRails-friendly DHTML grid? - ajaxКак создать приложение для iPhone в виде киоска? - iphonejQuery script doesn't work when viewing page on localhost - javascriptWPF - Temporarily stop data binding (data binding) - data-bindingCreating iPhone Applications for iPad - iphoneRoR application running on Mongrel but not manufacturing - ruby | fooobar.com.NET Timer controls are faster while the window is minimized - c #how to cut text of a certain length using php? - phpCut strings short php - stringAll Articles