Hi friends
am doing following to get nodes list from a xml file. it does not give me any error or gives me the nodes list
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load("c:\somefile.xml");
XmlNodeList entities = doc.selectnodes("SemanticModel/Entites") //this doesnot return anything. can you help plz
following is part of my xml file
<SemanticModel ID="Gc5212a1e-8db3-4d95-aaef-43202035958e" xmlns="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Description>Ctrl + Ls</Description>
<Culture>en-US</Culture>
<Entities>
<Entity ID="G006bc21c-a93d-4adf-b758-a503149b5d79">
<Name>General</Name>
<CollectionName>Generals</CollectionName>
<IdentifyingAttributes>
<AttributeReference>
<AttributeID>G67586644-87bd-41fd-8ff5-14bb6691f0cd</AttributeID>
</AttributeReference>
</IdentifyingAttributes>
<DefaultDetailAttributes>
<AttributeReference>
<AttributeID>G67586644-87bd-41fd-8ff5-14bb6691f0cd</AttributeID>
</AttributeReference>
<AttributeReference>
<AttributeID>G5a9fe083-5bf7-49f7-b42f-ab25caf1f49f</AttributeID>
</AttributeReference>
<AttributeReference>
<AttributeID>Ge54c10f8-fad2-4fcf-8dbe-d63dfeb4ab39</AttributeID>
</AttributeReference>
</DefaultDetailAttributes>
<DefaultAggregateAttributes>
<AttributeReference>
<AttributeID>G64fadd87-b7a0-4855-9ab0-52c9292d821d</AttributeID>
</AttributeReference>
</DefaultAggregateAttributes>
<InstanceSelection>FilteredList</InstanceSelection>
<Fields>
<Attribute ID="G64fadd87-b7a0-4855-9ab0-52c9292d821d">
<Name>No of General details</Name>
<DataType>Integer</DataType>
<Expression>
<Function>
<FunctionName>Count</FunctionName>
<Arguments>
<Expression>
<EntityRef>
<EntityID>G006bc21c-a93d-4adf-b758-a503149b5d79</EntityID>
</EntityRef>
</Expression>
</Arguments>
</Function>
</Expression>
<IsAggregate>true</IsAggregate>
<SortDirection>Descending</SortDirection>
<Format>n0</Format>
<EnableDrillthrough>true</EnableDrillthrough>
</Attribute>

why selectnodes method wont work?
VBProEd
You have a typo in the xpath, Entites instead of Entities. Try this
XmlNodeList entities = doc.selectnodes("/SemanticModel/Entities");
mr Umesh kumar
try:
XmlNodeList entities = doc.selectnodes("/SemanticModel/Entites")
or even
XmlNodeList entities = doc.selectnodes("//Entites")
ailuz
in my actual code there is no typo error. BTW since "semanticModel" is the root node, is it still required to add "/"
BTW i tried that one too but did not work :(
jpav2005
i tried both but did not make any difference unfortunately !!
eoinmullan
MetaMeta
XmlNode entities = doc.DocumentElement.ChildNodes[2];
but this i dont want to do it as my XML file may have more Entities so always want to select entities from a certain path.