- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 08:16 AM
I've got a UI Action that builds some XML. Here's a snippet.
<locations>
<location>
<locationNumber>1</locationNumber>
<locationSysID>a7ca11cadb84c74032afdd0b5e9619d3</locationSysID>
<address1>63 XXXXXX Dr</address1>
<address2/>
<city>XXXXXXX</city>
<province>36C67C486FB39500F210E062BE3EE45D</province>
<postalCode>L9A4H6</postalCode>
<buildingYear>1980</buildingYear>
<constructionType>1</constructionType>
<fus>1</fus>
<industryCodeLoc>6633</industryCodeLoc>
<industrySubCodeLoc>01</industrySubCodeLoc>
<occupancyCd>02</occupancyCd>
</location>
</locations>
The XML that results from my UI Action is going to be passed to our mainframe system via DataPower and MQ. The developer for these is indicating that he needs empty tags formatted as
<address2></address2>
In my example an empty tag shows as
<address2/>
I'm not familiar enough with XML to know if this is something I have control over. My google-fu is also failing to turn up an answer.
Is the format of the XML tags something I can control?
Here's the header of my XML:
<soapenv:Envelope xmlns="http://www.economical.com/ExtremeRating1.0.0/xml/" xmlns:cprp="http://CPRP_Rating" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 08:48 AM
Hi Sue,
Try adding a space when you creating the xml nodes for the ones that are empty. The space should get stripped when parsed but nodes would have a seperated end tag.
<address2> </address2>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 08:48 AM
Hi Sue,
Try adding a space when you creating the xml nodes for the ones that are empty. The space should get stripped when parsed but nodes would have a seperated end tag.
<address2> </address2>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 09:59 AM
Hi Venkat,
Thanks for the quick reply.
I tried this as a test of the SOAP message with a variable containing a space for the addr2 tag - that worked fine.
When I try this in my UI Action, the space is not stripped.
My code:
var addr2 = locationAddressText[1].trim();
If(addr2 == ''){
xmlDoc.createElementWithTextValue('address2', ' ');
} else {
xmlDoc.createElementWithTextValue('address2', locationAddressText[1].trim());
}
The result:
<address1>63 XXXXX Dr</address1>
<address2> </address2>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 10:41 AM
Try adding a space when you creating the xml nodes for the ones that are empty.
I would advise against that - you're actually changing the data to suit presentation purposes.
Null is not the same as space!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 10:50 AM
Hi Dave,
I would agree with you on it but the alternative if it was better is to handle that space at the receiving end as null attribute. Alternatively an XSLT would also benefit in this case.
