V1.0.3 XML node Error: Invalid character in name

Hi Guys,

I stack in a strange issue regarding convert JSON to XML in node-red v1.0.3. I have a code where I composing the specified XML for 3rd party server endpoint communication. The structure need to consist special characters like equation =

In the past it worked well to convert this JSON to XML using the built in XML node
{ "foo=":"bar"}

in v1.0.0 I got back this as the output of the XML node
"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><foo=>bar</foo=>"

but in v1.0.3 I get an error message in the debug window Error: Invalid character in name

Is there anybody who knows what I should change in JSON description to make the XML node to work for those special characters?

The xml node should work both ways. So a good way is to feed in the xml you want then see what json comes out. And then make you json look like that.

Are you sure that is valid XML? Try feeding it into an XML validator to check.

I’m not sure wether is valid or not but the structure of the XML is defined with the 3rd party endpoint. What I could manage to installed xml-js package and add to require this into node-red settings.js and use this idirectly from function node instead of built in xml node.

Now it works, but what changed between 1.0.0 and 1.0.3 which screw up in my app the xml node? Maxbe the package behind the xml node got new version?

As @colin said - it isn't valid xml. I'd be very wary of any API that claimed that it was. Are you sure that they really think it is ?

It's academic if it's valid XML or not. If it is the format the remote API requires then that is what is needed.

@roleeka between 1.0.0 and 1.0.3 the xml2js module we use was upgraded from version 0.4.19 to 0.4.22. So I would not have expected a breaking change to have occurred. I guess the face it isn't strictly valid XML as per the XML standard does give the module some leeway to change behaviour for edge cases like this. Unfortunately the xml2js module doesn't provide a changelog that lists changes in its releases, so I can't immediately tell you whether this was an 'expected' change. https://github.com/Leonidas-from-XIV/node-xml2js

I can't look at it any further right now.

If the older one allowed invalid XML to be generated that would be a bug fix. The improved validation of data will only break code that shouldn't have worked in the first place. I don't think that would normally be considered a breaking change.

1 Like

This url will show you all of the commits between the 2 versions.

Thanks the info, I had the same guess and agree to move into standard direction, but many cases you have to implement what you get as a specification and if the spec is non standard you have difficulties.

I think, we can close this topic, thanks the fast answers and luckily node-red flexible enough to include easily other npm nodes and my case the js-xls solved the problem after I included into setting.js and call it from function node.