I am new to using xml in c sharp. I am able to enter details to the xml file (name of file "Data1.xml") through text boxes.But before entering details to the xml file,i need to first verify if any other 'well' have the same 'name'. 'name' has to be unique. How to search the xml and find if there exist another well with the same name as in 'textbox1.text'???

Also,i need to get the 'name's of all 'well's and display in a datagridview.And get the value of 'density' and 'depth' in textboxes,for a particular well,on clicking the row in grid view.
may be this is simple,but please help me with this.i always find great help in daniweb,and expect it this time too..
Thanks in advance.

<?xml version="1.0" encoding="utf-8"?>
<wells>
  <well>
    <name>abc</name>
    <density>1000</density>
    <depth>200</depth>
  </well>
</wells>

help the user schema describes the structure of the medium and the content of xml file
this man need no additional programming required to operate

http://www.xml.com/pub/a/2000/11/29/schemas/part1.html

so can create an xsd file

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="wells">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="well"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="well">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="name"/>
        <xs:element ref="density"/>
        <xs:element ref="depth"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="name" type="xs:string"/>
  <xs:element name="density" type="xs:integer"/>
  <xs:element name="depth" type="xs:integer"/>
</xs:schema>

to use in xml file write this

<?xml version="1.0" encoding="utf-8"?>
<wells xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="wells.xsd">
	<well>
		<name>abc</name>
		<density>1000</density>
		<depth>200</depth>
	</well>
</wells>

if one is working with the xml file
use a lot of programming languages ​​as the parser check and throw an exception and then break the reading from the xml

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.