Click here to Skip to main content
15,125,968 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to remove node
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
and at the end in asp.net with c#.
My Xml String is as below:
<?xml version="1.0" encoding="utf-16"?><Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><webServiceRequest><entityDetails><entityId>123</entityId><userName>TEST</userName><password>TEST123</password><serviceId>12344321</serviceId><requesterWsiRef>WSI334317863373136178</requesterWsiRef></entityDetails><requestDetails><encrypyedRequestKeyData>fye1gPxpyejR35ziHJyAAQ==</encrypyedRequestKeyData><encryptedRequestData>o9mKUt4fdQHFoAMKMP+4UB8PCJItb5JZS9FszbvbM3Wg5fc8UWdGQxOCMNVieQjNgOtNebTY5xLnH41jOErJ/F5W2rY/KZrstrZZ76ifpjjtcCj/sgkcs3RoL5CnoBEpNaqWdr1c6/WXf2mKG9qSpcFy8nJACS0pDBCUFSFfXBICiLJZBM6puSl5LYcGcBq9N9tvtQrcHtK5OhxKSh4tw8/dYY7/iF4rJYR1feBLFSko0jrCBilGR4hq8JHLqDt0ei7hzdbUF5VoXYyy1W4eedias/vZlQbVFO7ut/M83NaghO/rxcd1c06KjQAHUa8L2Ue85zNUaaSMCGB2GOEpcoPtz2+8l92sR4lFVPTfLO1lTlrdaLPrN2ZGVg5P8z1U+2aRbxHgCJVNYwDTwEdHA8M5YlzWEpGeWC5RzkfhT3Df9OZLYdCImY+bSm+S4PIYr7yJGUXw2rA8581d6SeTvUvjhfBDxQ7srNK1lv0ucKzi7SmlzPF+Dj8HvugloZkgYwQZuoH4RyF9DpEDMnFGZMc9Ic4Fhjw26DDi13DIxK0pPIGv3Z6t/z6K82yIvI6rrLtLcEwhbbYr4tD6t8PaAvOXHIxYQXthTFEt3TsJQ/Cof5DSopzS0m7tyP9bStoF8WstwHuq7Rpdxe58oOc0AoB0Qm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QcIpUl/9FasJ7ZKwbHx7tPTpTDMwJXT7iBqDcEvmEbh8R4Ie2kMlwXAgE/5S/XNjDCh6w4p5sx7sCmsbVOhn4I5JHWXMzOFfLmfc3+C7kEvdtJr0u+DqMC/NjlD8AJoOcUtuYpBGJnB46xq/7NkNEmGZsSu4njniazv9/01O4e9YntusrL3XwFWYhQtemphGnAmdtJ0uTpu2A9X/a8HE9U3aKFAmt2KJM3VSEpg3dqfxYMvI+nSBZltMoWoLSTv4tMojpbutYalaPPexDXkc5dOmgdpNrDXkikxml6uJilx5M5AdjYmOX/6E01Rpd+USUTz7WDGRHavWDSpKNwSKSA0tAGLsswz2JzAO7f9uw4JuqyG/qraccDz8y+zXL/M2PM1YoAjqkmzl5UZRH8unw3ePloe7Y4U/AiuoZbaeGcqpAE04awHHkIobsmv7tdSq4Ss6zz3l4otFygRdc0v345vmEYH84Wkk/nPrBoyoNl6fNT+xZWR/ZCu3had3USHUIMRWUAqBbUkVDnvYlG3fL1xW+aIXmZqTc1dduEJZobsqvUei9Ol/B88lYZ1f4aTjSpB8IUndXM0c5xHmnwBMUrGazza/cQ7brbwmQI3nk1yxsRa1mWdWucvRCEcd6AQy4A5rqlONAwsydHDg7SDCniSJf7Fg9B+w+KF0bxZogkkpqie+tpXyast3aGCxI+6B8Dyk3Jvq1Wv15+Jbjr4pp9JZc1J9zxyzSEaWpau6LEsnGBgiaBU66IDljJAgQsZiDXQusG6qH9LV0ixRFYvCgl+jYPBMYNF+7uCG/wlt2LhOK3itY2BWi2V2qXP3+m3eyJIZ2XBnFuisT2GzDT9Oco7dMRPKZvieYXYL68zYyRDhqKb6pf6iVrtO0H1baHt5MHauBB2Yv6pPc4vhW053nE3wRvkqrnHRupGTOasjYeYADT1WsQ++VNtb/9MUDMiKDACWdehnuOxrkHj7Gqu7zoCTeiw==</encryptedRequestData></requestDetails></webServiceRequest></Request>


What I have tried:

My Xml String is as below:
<pre><?xml version="1.0" encoding="utf-16"?><Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><webServiceRequest><entityDetails><entityId>123</entityId><userName>TEST</userName><password>TEST123</password><serviceId>12344321</serviceId><requesterWsiRef>WSI334317863373136178</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/7oBnB2xvfp2x/zpiMrhTYUxluz6JgvWrEoo80eRosFPLXNvq1VS+cZo5fS2aGdIoX+tPucSAzRG56jW5CBpuX0GRwmTAzBXjuuzN1CUY+I+b7dvKgAyKqrgLxJgITK8kBX3T6ec54QDMJYHEnYHrHMlXsQ1DqJo1OV3VDGU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GnAmdtJ0uTpu2A9X/a8HE9U3aKFAmt2KJM3VSEpg3dqfxYMvI+nSBZltMoWoLSTv4tMojpbutYalaPPexDXkc5dOmgdpNrDXkikxml6uJilx5M5AdjYmOX/6E01Rpd+USUTz7WDGRHavWDSpKNwSKSA0tAGLsswz2JzAO7f9uw4JuqyG/qraccDz8y+zXL/M2PM1YoAjqkmzl5UZRH8unw3ePloe7Y4U/AiuoZbaeGcqpAE04awHHkIobsmv7tdSq4Ss6zz3l4otFygRdc0v345vmEYH84Wkk/nPrBoyoNl6fNT+xZWR/ZCu3had3USHUIMRWUAqBbUkVDnvYlG3fL1xW+aIXmZqTc1dduEJZobsqvUei9Ol/B88lYZ1f4aTjSpB8IUndXM0c5xHmnwBMUrGazza/cQ7brbwmQI3nk1yxsRa1mWdWucvRCEcd6AQy4A5rqlONAwsydHDg7SDCniSJf7Fg9B+w+KF0bxZogkkpqie+tpXyast3aGCxI+6B8Dyk3Jvq1Wv15+Jbjr4pp9JZc1J9zxyzSEaWpau6LEsnGBgiaBU66IDljJAgQsZiDXQusG6qH9LV0ixRFYvCgl+jYPBMYNF+7uCG/wlt2LhOK3itY2BWi2V2qXP3+m3eyJIZ2XBnFuisT2GzDT9Oco7dMRPKZvieYXYL68zYyRDhqKb6pf6iVrtO0H1baHt5MHauBB2Yv6pPc4vhW053nE3wRvkqrnHRupGTOasjYeYADT1WsQ++VNtb/9MUDMiKDACWdehnuOxrkHj7Gqu7zoCTeiw==</encryptedRequestData></requestDetails></webServiceRequest></Request>
Posted
Updated 3-Jul-18 5:30am
Comments
Mike V Baker 3-Jul-18 10:33am
   
There's not enough information here to figure out what you mean. Which 'node' are you trying to remove? Do you actually want to remove it or just read it with code so you can do something with it. When you post 'what I have tried' we actually need to see the C# code that you're using in your attempts, not just the XML string again.
I'm happy to help resolve specific issues in logic or syntax errors, but with this information I can't tell where the ball park is.

1 solution

Parse the document using the XDocument class.

You do realize that by removing the <Request> element the only thing left will be the XML Declaration, right?
   
v2

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