Как получить значения узлов в XML с помощью ASP.NET с помощью C#?
Я хочу получить значение узла encryptedRequestData и encryptedrequestkeydata в строке xml с помощью asp.net с помощью c#.
Попытался получить метод имени тега
XmlNodeList nodeList = xmldoc.GetElementsByTagName("/webServiceRequest/ requestDetails/encryptedRequestData/");
Моя Xml строка выглядит следующим образом:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><webServiceRequest><entityDetails><entityId>123</entityId><userName>TEST</userName><password>TEST123</password><serviceId>12344321</serviceId><requesterWsiRef>WSI616278092294763973</requesterWsiRef></entityDetails><requestDetails><encrypyedRequestKeyData>fye1gPxpyejR35ziHJyAAQ==</encrypyedRequestKeyData><encryptedRequestData>o9mKUt4fdQHFoAMKMP+4UB8PCJItb5JZS9FszbvbM3Wg5fc8UWdGQxOCMNVieQjNgOtNebTY5xLnH41jOErJ/F5W2rY/KZrstrZZ76ifpjjtcCj/sgkcs3RoL5CnoBEpNaqWdr1c6/WXf2mKG9qSpcFy8nJACS0pDBCUFSFfXBICiLJZBM6puSl5LYcGcBq9N9tvtQrcHtK5OhxKSh4tw8/dYY7/iF4rJYR1feBLFSko0jrCBilGR4hq8JHLqDt0ei7hzdbUF5VoXYyy1W4eedias/vZlQbVFO7ut/M83NaghO/rxcd1c06KjQAHUa8L2Ue85zNUaaSMCGB2GOEpcoPtz2+8l92sR4lFVPTfLO1lTlrdaLPrN2ZGVg5P8z1U+2aRbxHgCJVNYwDTwEdHA8M5YlzWEpGeWC5RzkfhT3Df9OZLYdCImY+bSm+S4PIYr7yJGUXw2rA8581d6SeTvUvjhfBDxQ7srNK1lv0ucKzi7SmlzPF+Dj8HvugloZkgYwQZuoH4RyF9DpEDMnFGZMc9Ic4Fhjw26DDi13DIxK0pPIGv3Z6t/z6K82yIvI6rrLtLcEwhbbYr4tD6t8PaAvOXHIxYQXthTFEt3TsJQ/Cof5DSopzS0m7tyP9bStoF8WstwHuq7Rpdxe58oOc0AoB0QmZI/+Y1Pe4qAs6iD8IstJw/7oBnB2x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g0tG7KWflrUJLsZbL2TzCt3i1KoVIiNIgAI5vdL9XbuUxIlV0j3BfQPL7P0N5pRXxXJ2gRSIWWLpQsg27GWoB4I/jufFkgxuSY/in57MCGbVWZgWW7G/QABvS0gY8UBM9jR3fzsuDTI+pTJuAJwJE+1BzERv2U2KpahjD3orO2gCH5YZ4pZgI9hppi7OIABueixWrHPIrvQZWVgPj4xYgZDl8505DkQqZt34c9siMx6cr0fw6guZZhUwW/w6PrGjqV1YT/Tt+t711Krn1Lg013ConyCip4BPDpWQpfNcG623M7/gHr9IEdH/0gKNQbPS4CDA6YEHXXpHnow26moONdWVeJhUqoavy9dj4AJzoMfFy9jsNUQs+2/ckmXlq8t1bxe7jUenl9KQe5cAUuF1Hbr5OAuiqxc2A+9bhCxbXUwibuNOxJXW+cAsatMpsM3J4zZSG9qPWdRsy+slfHPDE3bhLa8JdfU96SPgQjN+38e3onUWF5xOrazIkr84rBgNQJDfO9kt7bD7lm7xuI88fBtCHI19QHujkfuCkU4tc90xpui8jwBRVRt9r/z/woNo8w4ab1+QYGgudu9vPVHMAVDe6/nyF0pAp71Vd/xlUNF6c1wHKMhRYV9u9DLUOqqpg6XwRny3eIk3U1IemAr8p2uMg7kH4hEvjPPdNfps61uOi3xsgiKGiCQba/BkmBNHWBgfDLyo2ptoAQvSFvNA21SA102Vbtk6XuGrr0PGLciRY2D4Z12hjs9BRA4nAspg5aVX1WDKBTGf08RLDs3fKveTwCQ2LawaFzcxaj9VXilgKLFtfWT1LYlPq0vIJ4ezM1/ZuZKkMVda11SJqyJaG2blRP43fstzkgPFtAsGVLlQEkEwI3rRBSva8Fo0x3o1wHVKvsAve2idiWGpueDEaIxfX0KGCotf2nQEg==</encryptedRequestData></requestDetails></webServiceRequest>
Что я уже пробовал:
Основной код выглядит следующим образом:
try { XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(objAPI.ReqAPI); XmlNodeList nodeList = xmldoc.GetElementsByTagName("/ webServiceRequest/requestDetails/encryptedRequestData/"); string Short_Fall = string.Empty; foreach (XmlNode node in nodeList) { objAPI.AES_Encrypted_key = node.InnerText; } } catch(Exception ex) { }
F-ES Sitecore
используйте SelectSingleNode
https://msdn.microsoft.com/en-us/library/fb63z0tw(v=против 110).aspx
Zdenek Sedlak
Эти пробелы после " / " в обоих примерах являются намеренными?