Issue with replacing value of XML element attribute

Hi,

I want to replace several values in an XML file and I have an issue with replacing the value of the cbc:EndpointID. See under for the XML structure.

  <cac:ContractorCustomerParty>
    <cac:Party>
      <cbc:EndpointID schemeID="0192">123456789</cbc:EndpointID>
      <cac:PartyIdentification>
        <cbc:ID schemeID="0192">123456789</cbc:ID>
      </cac:PartyIdentification>
      <cac:PartyName>
        <cbc:Name>NameOfBuyer</cbc:Name>
      </cac:PartyName>
    </cac:Party>
  </cac:ContractorCustomerParty>

I have succesfully managed to replace other values with an invoke code activity with the following code:

in_DeserializedXML.Element(in_NsCatalogue+"Catalogue").Element(in_NsCac+"ContractorCustomerParty").Element(in_NsCac+"Party").Element(in_NsCac+"PartyName").Element(in_NsCbc+"Name").ReplaceWith(in_OrgName);

However, when I attempt to change the value of an element with a space in the element name I recieve the following exception:

Exception -The ' ' character, hexadecimal value 0x20, cannot be included in a name

Has anyone experienced a similiar issue or do you have an idea on a workaround?

Thanks,
JM

Hello @joergen_moeller

Here in cbc:EndpointId, where is the space? If you doubt about a space can you use Trim to remove the unwanted spaces. Also sharing a previous post which discussed about the data fetching from xml.

1 Like

@Rahul_Unnikrishnan

The only space I can find the space within the element name itself (cbc:EndpointID SPACE schemeID=“0192”). I have tested with trimming the element name, but as you would expect it has to be consistent.

I have looked through the link you attached but it did not help me solve the issue.

@joergen_moeller

Can you check the below post.

1 Like

Thank you, @Rahul_Unnikrishnan.
By reading the last thread you posted I understood that you do not need to specify the schemeID within the namespace. Only refering to EndpointID is sufficient.

For anyone that may experience this issue the solution is to exclude the scheme ID within the element name:

DeserializedXML.Element(NsCatalogue+"Catalogue").Element(NsCac+"ContractorCustomerParty").Element(NsCac+"Party").Element(NsCbc+"EndpointID").Value
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.