I wish to get value of Element “name” which is inside “homecity”. (see the xml below)
Here is what I’ve tried -
Read XML using Read Text File activity and stored the output in “xmlContent” variable.
Used the Parse method to parse the xmlContent from Step 1, assigned to a XDoc variable of XDocument type.
Used, XDoc.XPathSelectElement(“//homecity/name”).Value and assigned this to a “cityName” variable.
NOTE: Have also tried Deserializing XML. And, when I remove the xmlns="http://www.your.example.com/xml/person" from person and "xmlns="http://www.your.example.com/xml/cities" from homecity, it works.
After executing this getting Runtime execution error -
Source - Assign (Step 3)
Message - Object reference not set to an instance of an object
Exception Type: System.NullReferenceException
But I don’t wish to have the namespaces added to data sheet. Is there anyway I can get the element value from the given xml (mentioned in my question) or anyway to just ignore the namespaces and read the rest of the xml.
it is not about to setup a config and namespaces to a config table. It was about to show you the essentials on how to setup up the namespace manager needed for the XPathSelectElement
we had shown you two approaches and did answer how to handle XML Namespaces
not really recommended, as we can properly handle the Namespaces