Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have unstructured XML as shown below

<Root name="FIRST" serviceidentifier="">
  <SERVER response="SERVICE NOT FOUND" type="SERVER" identifier="NONE" misc="NOT FOUND"/>
</Root>
<Root name="SECOND" serviceidentifier="">
  <SERVER response="SERVICE NOT FOUND" type="SERVER" identifier="NONE" misc="NOT FOUND"/>
</Root>	
<Root name="FIRST" serviceidentifier="">
  <SERVER response="SERVICE NOT FOUND" type="SERVER" identifier="NONE" misc="NOT FOUND"/>
</Root>


I Have to find the line number of the XML which has duplicate nodes with the attribute "FIRST" like "Root name=FIRST"

What I have tried:

I am New to XML So please give me a Complet CODE

Thanks for your help .....
Posted
Updated 11-Jun-17 20:21pm
Comments
Thanks7872 12-Jun-17 5:12am    
'What I have tried' is meant to provide clarification on What have you tried. 'I am New to XML So please give me a Complet CODE' is not a valid text for that section. At least try something and come back with the problems you are facing. Nobody here will be happy to 'give you Complete Code'.

1 solution

Your first and most severe problem is that this is not an XML (not valid), so you can not load it into an XmlDocument[^] object...
So first wrap it into a virtual root make it valid XML, than use XMLDocument and XPath to find elements with the same attributes...
XPath Examples[^]
[^]
Select Nodes Using XPath Navigation | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900