Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
XPath
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Xml.Linq; using System.Xml.XPath; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here var xmlElement = RemoveAllNamespaces( XElement.Parse(@"<?xml version=""1.0"" encoding=""utf-8""?><soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <soap:Body> <BEMA_CALCULARPAGAMENTOResponse xmlns=""http://tempuri.org/""> <BEMA_CALCULARPAGAMENTOResult> <OPERACAOOK>N</OPERACAOOK> <ID>0</ID> <SEQITEMGRID>0</SEQITEMGRID> <MENSAGEMERRO>BemaWSErro no servidor. ORA-12545: Connect failed because target host or object does not exist</MENSAGEMERRO> <VLPARCELA>0</VLPARCELA> <NRTABELAITAU>0</NRTABELAITAU> <LISTITENS /> <LISTFORMAS /> <LISTSERVICOSSUBSTITUIDOS /> </BEMA_CALCULARPAGAMENTOResult> </BEMA_CALCULARPAGAMENTOResponse> </soap:Body></soap:Envelope>")); var xmlResponse = XDocument.Parse(xmlElement.ToString()); var xmlNavigator = xmlResponse.CreateNavigator(); var dicEx = new Dictionary<string, string>() { { "N", "/Envelope/Body/BEMA_CALCULARPAGAMENTOResponse/BEMA_CALCULARPAGAMENTOResult/OPERACAOOK"} }; foreach (KeyValuePair<string, string> entry in dicEx){ foreach (XPathNavigator node in xmlNavigator.Select(entry.Value)) { Console.WriteLine("{"+entry.Key+"}{"+entry.Value+"}"); } } } public static XElement RemoveAllNamespaces(XElement e) { return new XElement(e.Name.LocalName, (from n in e.Nodes() select ((n is XElement) ? RemoveAllNamespaces(n as XElement) : n)), (e.HasAttributes) ? (from a in e.Attributes() where (!a.IsNamespaceDeclaration) select new XAttribute(a.Name.LocalName, a.Value)) : null); } } }
run
|
edit
|
history
|
help
0
Carnival 1.0
GGT
DAY !
Switch
10
tst
Test
per1
Консоль. Депозит
3. Delegates and events: closure