Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Element Names
Message
Information générale
Forum:
ASP.NET
Catégorie:
XML
Titre:
Divers
Thread ID:
01362922
Message ID:
01363674
Vues:
9
>>I can't trust that the data file hasn't changed, so currently I'm using SelectSingleNode with a full path to locate them. (Partial paths don't seem to work or I don't know the syntax.) The path syntax seemed simpler for doing it this way, so that was part of what I liked. There is another collection because DataFiles is also a collection. I'm using this XML to track the file as it goes through a conversion process. It will retain some information such as the original field name and what the field is used for that cannot be stored in a free table.
>>
>
>>They're are a lot of XML techniques I don't really know yet, and I may have some confusion on how it all works. So... any sample code you can point me to on "iterate over just those elements "? At the moment, that seems harder to do with 'Field Name="NM"' than it is with just the element "NM" because I have to do a lookup for the name attribute, rather than the just looking at the nodes name property.
>
>This might not make sense in the context of how you're processing things (it may be easier to just use a normal XML document and iterate manually over child nodes once you've gotten the parent), but you can use LINQ to do this kind of thing:
>
>
>string xml = @"<?xml version='1.0'?>
><DataFiles>
>  <DataFile Source='' FileType='DBF' FileName='run.dbf'>
>	<Fields>
>	  <NM />
>	  <DEPT />
>	  <CO />
>	  <AD />
>	  <CTY />
>	  <ST />
>	  <ZIP />
>	</Fields>
>  </DataFile>
></DataFiles>";
>
>System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Parse(xml);
>
>var result = from fields in doc.Descendants("Fields")
>	 from element in fields.Descendants()
>	 select element.Name;
>
>foreach (string name in result)
>   Console.WriteLine(name);
>
Thanks!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform