You can use XmlDocument.GetElementsByTagName Method (String) to get elements by its name. It will return an
XmlNodeList containing a list of all descendant elements that match the specified
Name. After that, you can loop all node in this nodelist to check your conditions.
Member
73 Points
43 Posts
Sibling of (Parent of current Node) XPATH
Aug 28, 2014 09:44 AM|Rajesh Mishra|LINK
HI,
I have XML source like:
I am inside for-each of <Element> tag inside <RepeatingSegment type="EB">
I need to check if next sibling of <RepeatingSegment type="EB"> is <RepeatingSegment type="MSG">, then print 'The Message'.
Again need to check if 'MSG' segment exists, then print 'The Message', till different segment reached.
** (Using XSLT) ** Any help near this or selecting next sibling of (parent of current node) will be helpful.
xslt XPATH xml HTML
Rajesh Mishra
Senior Development Engineer
Participant
1194 Points
122 Posts
Re: Sibling of (Parent of current Node) XPATH
Aug 29, 2014 05:52 AM|George Hua - MSFT|LINK
Hi Rajesh,
You can use XmlDocument Class to read this XML file.
You can use XmlDocument.GetElementsByTagName Method (String) to get elements by its name. It will return an XmlNodeList containing a list of all descendant elements that match the specified Name. After that, you can loop all node in this nodelist to check your conditions.
You may find this thread helpful:
Read XML Attribute using XmlDocument
Regards,
George.
xslt XPATH xml HTML
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
Member
73 Points
43 Posts
Re: Sibling of (Parent of current Node) XPATH
Aug 31, 2014 03:09 AM|Rajesh Mishra|LINK
Hi George,
Please excuse me for not mentioning that I need to do this using XSLT. I have gone far ahead to come back and use c sharp for reading this XML.
Thanks and Regards,
Rajesh Mishra
xslt XPATH xml HTML
Rajesh Mishra
Senior Development Engineer
Participant
1194 Points
122 Posts
Re: Sibling of (Parent of current Node) XPATH
Sep 01, 2014 10:04 PM|George Hua - MSFT|LINK
Hi Rajesh,
Thanks for your information.
You can also read XSLT files through XmlDocument class, it might look like this:
Regards,
George.
xslt XPATH xml HTML
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.