Bonjour, je debute en C# et xml...j'essaie de trouver un moyen de lire mon fichier xml et d'acceder a la bonne donnee. Ex: voici mon fichier XML
j'aimerai entrer un txtRechercher.Text qui est FirstNameet et affiche FirstName et et LastName dans un gridview s'il existe sinon un message qui s'affiche qu'il n'existz pas
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 <?xml version="1.0" standalone="yes"?> <ContactDataSet xmlns="http://tempuri.org/ContactDataSet1.xsd"> <xs:schema id="ContactDataSet" targetNamespace="http://tempuri.org/ContactDataSet1.xsd" xmlns:mstns="http://tempuri.org/ContactDataSet1.xsd" xmlns="http://tempuri.org/ContactDataSet1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="ContactDataSet" msdata:IsDataSet="true" msdata:Locale="en-US"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="Contact"> <xs:complexType> <xs:sequence> <xs:element name="ContactID" type="xs:string" minOccurs="0" /> <xs:element name="NameStyle" type="xs:string" minOccurs="0" /> <xs:element name="Title" type="xs:string" minOccurs="0" /> <xs:element name="FirstName" type="xs:string" minOccurs="0" /> <xs:element name="MiddleName" type="xs:string" minOccurs="0" /> <xs:element name="LastName" type="xs:string" minOccurs="0" /> <xs:element name="Suffix" type="xs:string" minOccurs="0" /> <xs:element name="EmailAddress" type="xs:string" minOccurs="0" /> <xs:element name="EmailPromotion" type="xs:string" minOccurs="0" /> <xs:element name="Phone" type="xs:string" minOccurs="0" /> <xs:element name="PasswordHash" type="xs:string" minOccurs="0" /> <xs:element name="PasswordSalt" type="xs:string" minOccurs="0" /> <xs:element name="AdditionalContactInfo" type="xs:string" minOccurs="0" /> <xs:element name="rowguid" type="xs:string" minOccurs="0" /> <xs:element name="ModifiedDate" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema> <Contact> <ContactID>1</ContactID> <NameStyle>false</NameStyle> <Title>Mr.</Title> <FirstName>Michel</FirstName> <LastName>Bakary</LastName> <EmailAddress>gustavo0@adventure-works.com</EmailAddress> <EmailPromotion>2</EmailPromotion> <Phone>398-555-0132</Phone> <PasswordHash>GylyRwiKnyNPKbC1r4FSqA5YN9shIgsNik5ADyqStZc=</PasswordHash> <PasswordSalt>TVGHbhY=</PasswordSalt> <AdditionalContactInfo><AdditionalContactInfo xmlns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo" xmlns:crm="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRecord" xmlns:act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"><act:telephoneNumber><act:number>425-555-1112</act:number><act:SpecialInstructions>Call only after 5:00 p.m.</act:SpecialInstructions></act:telephoneNumber>Note that the customer has a secondary home address.<act:homePostalAddress><act:Street>123 Oak</act:Street><act:City>Seattle</act:City><act:StateProvince>WA</act:StateProvince><act:PostalCode>98001</act:PostalCode><act:CountryRegion>USA</act:CountryRegion><act:SpecialInstructions>If correspondence to the primary address fails, try this one.</act:SpecialInstructions></act:homePostalAddress>Customer provided additional email address.<act:eMail><act:eMailAddress>customer1@sample.com</act:eMailAddress><act:SpecialInstructions>For urgent issues, do not send e-mail. Instead use this emergency contact phone<act:telephoneNumber><act:number>425-555-1111</act:number></act:telephoneNumber>.</act:SpecialInstructions></act:eMail><crm:ContactRecord date="2001-06-02Z">This customer is interested in purchasing high-end bicycles for his family. The customer contacted Michael in sales.</crm:ContactRecord></AdditionalContactInfo></AdditionalContactInfo> <rowguid>d4c132d3-fcb5-4231-9dd5-888a54bec693</rowguid> <ModifiedDate>2005-05-16T16:33:33.06+02:00</ModifiedDate> </Contact> <Contact> <ContactID>2</ContactID> <NameStyle>false</NameStyle> <Title>Ms.</Title> <FirstName>Catherine</FirstName> <MiddleName>R.</MiddleName> <LastName>Abel</LastName> <EmailAddress>catherine0@adventure-works.com</EmailAddress> <EmailPromotion>1</EmailPromotion> <Phone>747-555-0171</Phone> <PasswordHash>zh3goJUbYsPv92k4bVZuJtlLHwuvpQtu6uNcjkKSdF8=</PasswordHash> <PasswordSalt>rpyd5Tw=</PasswordSalt> <AdditionalContactInfo><AdditionalContactInfo xmlns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo" xmlns:crm="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRecord" xmlns:act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes">These are additional phone and pager numbers for the customer.<act:telephoneNumber><act:number>206-555-2222</act:number><act:SpecialInstructions>On weekends, contact the manager at this number.</act:SpecialInstructions></act:telephoneNumber><act:telephoneNumber><act:number>206-555-1234</act:number></act:telephoneNumber><act:pager><act:number>206-555-1244</act:number><act:SpecialInstructions>Do not page between 9:00 a.m. and 5:00 p.m.</act:SpecialInstructions></act:pager>Customer provided this additional home address.<act:homePostalAddress><act:Street>P.O Box 5</act:Street><act:City>Edmonds</act:City><act:StateProvince>WA</act:StateProvince><act:PostalCode>98431</act:PostalCode><act:CountryRegion>USA</act:CountryRegion><act:SpecialInstructions>This is an alternative address for billing only.</act:SpecialInstructions></act:homePostalAddress><act:eMail><act:eMailAddress>Joe@sample.com</act:eMailAddress><act:SpecialInstructions>Do not send e-mail for urgent issues. Use telephone instead.</act:SpecialInstructions></act:eMail><crm:ContactRecord date="2001-07-02Z">Sales contacted this customer to explain new pricing.</crm:ContactRecord></AdditionalContactInfo></AdditionalContactInfo> <rowguid>d54e0552-c226-4c22-af3b-762ca854cdd3</rowguid> <ModifiedDate>2005-05-16T16:33:33.077+02:00</ModifiedDate> </Contact>
et je n'ai aucune idee de comment faire je ne sais pas quoi utiliser entre XmlDocument, dataSet, xmlReader...
et merci d'avance
Partager