Just Simply Code

Another developer blog

  • Home
  • About
  • Register
  • Policy

XML

Find a child node from XmlNode with ignoring namespaces

19 June 2022 / Leave a Comment

Given a XmlNode object, I needed to get the first children node by name. I used the SelectSingleNode method, providing a valid Xpath, but it didn’t work. For example, I need to get the first child node named Signature from the xmlNode It took me a bit of time to realise that the Signature node … [Read more…]

Posted in: Uncategorised Tagged: .Net Core, XML

Digitally sign XML content with signing certificate

14 February 2021 / Leave a Comment

In this post, I showed how to verify XML digital signature or XmlDSig. In this post, I’m going to show how to sign an XML using a signing certificate. For the XmlDSig to be valid, it requires a custom Filter transformation. This tells which node in the XML content to be signed. Then, we add … [Read more…]

Posted in: Uncategorised Tagged: Digital signing, XML, XmlDSig

Verifying if two XML strings are equivalent using XmlDiffPatch

25 October 2020 / Leave a Comment

I come across a requirement for one of my projects where I need to check if two XML strings are equivalent. They might not be exact match (that would be too easy, a strings compare would do), nor have same namespaces, prefix and child order. Also, I want to be able to exclude certain nodes … [Read more…]

Posted in: Uncategorised Tagged: XML, XmlDiffPatch

XML manipulation using XDocument

5 July 2020 / Leave a Comment

One of my recent tasks at work requires some XML manipulations. This includes reading value of an XML element, changing an element value, reading values of children nodes and reading the outer XML value of an element. In this post, I’m going to show how to do these using XDocument in .Net Core. We’ll use … [Read more…]

Posted in: Uncategorised Tagged: .Net Core, XDocument, XML

Return string as raw XML with content type text/xml in .Net Core web API

7 June 2020 / Leave a Comment

In one of my recent projects at work, I have to build a web API which simply returns a XML string as raw XML in the response. The response header also needs to have a content type of text/xml. The endpoint will always returns XML, result is already an XML string and not some objects … [Read more…]

Posted in: Uncategorised Tagged: .Net Core, WebAPI, XML

Serialising object to XML with different default namespace and root name

3 August 2019 / Leave a Comment

I have a need to override the default namespace and change the root name when serialising object to XML string. I could add XmlType attribute and change the namespace and add XmlRoot attribute for a different root name. However, we have different clients and each requires different namespace and root name. So I need to … [Read more…]

Posted in: Uncategorised Tagged: Deserialisation, Serialisation, XML

Verifying XML digital signature with Chilkat

8 June 2019 / Leave a Comment

In the previous post, I showed how to verify XML digital signature using SignedXml object from namespace System.Security.Cryptography.Xml. However that method could only verify signatures signed by .Net and fails to verify a valid signature signed via front end using Javascript or a valid signature with custom transform nodes. Chilkat is not a free library … [Read more…]

Posted in: Uncategorised Tagged: XML, XmlDSig

Verifying XML digital signature

26 May 2019 / Leave a Comment

In my last post, I showed how to read an XML digital signature. In this post, I’m going to show how to verify the XML digital signature to check if it’s valid or not.

Posted in: Uncategorised Tagged: XML, XmlDSig

Reading XML Digital Signature value

12 May 2019 / Leave a Comment

For a project I’m working on, I have to read in an XML digital signature – XmlDSig. In this post, I’m going to show how to read an XmlDsig value using SignedXml object from namespace System.Security.Cryptography.Xml. I add a class to hold my signature data The following is the function to read the XmlDsig value

Posted in: Uncategorised Tagged: XML, XmlDSig

Deserialising XML string without namespaces

16 March 2019 / Leave a Comment

I have a xml string without any namespaces that needs to deserialise to an object that has namespace in XmlType attribute. When I try to deserialise it with XmlSerializer, all my properties are not populated. To fix it, I need to add my own XmlTextReader that will replace it with the namespace from class. I … [Read more…]

Posted in: Uncategorised Tagged: Deserialisation, XML

Search Posts

Recent Posts

  • Override IHttpRequestBodyDetectionFeature.CanHaveBodyOverride value in .NET Core Web API
  • Allow empty request body in PUT and POST HTTP requests in .NET Core Web API
  • Modify request body with middleware in .NET Core Web API
  • Running MS Orleans on AWS ECS
  • Respect leading and trailing spaces when querying SQL Server
Support my blog here!Support my blog!

Archives

  • July 2024
  • June 2024
  • July 2023
  • April 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • October 2017
  • September 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • July 2016
  • June 2016
  • March 2016
  • February 2016
  • January 2016

Copyright © 2025 Just Simply Code.

Me WordPress Theme by themehall.com