Reputation: 95
I have xml data with node name as a numeric value and i need to retrieve the node with that name.
when i use the below code it throws the exception "Expression must evaluate to a node-set."
Code:
`lSampleXml.SelectSingleNode("//" & lClass.Name)`
where lClass.Name is a numeric value = 6556 casted into string.
Please help to get rid of the exception.
Sample XML :
<Root>
<6556>
<Data> </Data>
<Text> </Text>
</6556>
<1223>
</1223>
<Phone>
</Phone>
</Root>
Upvotes: 1
Views: 1016
Reputation: 167716
Well an XML name (like an element name or attribute name) can't start with a digit so having <6556>...</6556>
is not possible as well-formed XML and thus a path expression //6556
as well is not meaningful as a way to select elements of that name.
So you should get an error when trying to parse your markup sample.
Upvotes: 3