Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <ns0:Entity xmlns:ns0="http://schemas.mycompany.com/1.0">
- <ns0:Data>
- <Address_Id xmlns:ns0="http://schemas.mycompany.com/1.0">7</Address_Id>
- <Customer_Id xmlns:ns0="http://schemas.mycompany.com/1.0">67</Customer_Id>
- <CustomerName xmlns:ns0="http://schemas.mycompany.com/1.0">My Customer 1</CustomerName>
- </ns0:Data>
- </ns0:Entity>
- private static string GetValue_Attempt1(XPathDocument xPathDocument, string xpathExpression)
- {
- var xpathNavigator = xPathDocument.CreateNavigator();
- var xpathNodeIterator = xpathNavigator.Select(xpathExpression);
- xpathNodeIterator.MoveNext();
- return xpathNodeIterator.Current.Value;
- }
- private static string GetValue_Attempt2(XPathDocument xPathDocument, string xpathExpression)
- {
- var xpathNavigator = xPathDocument.CreateNavigator();
- var xpathNodeIterator = xpathNavigator.Select(xpathExpression);
- xpathNodeIterator.MoveNext();
- var nodesNavigator = xpathNodeIterator.Current;
- var nodesText = nodesNavigator.SelectDescendants(XPathNodeType.Text, false);
- nodesText.MoveNext();
- return nodesText.Current.Value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement