Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
Suraj Borade
153
Views
9
Comments
Replace line in generated XML
Question
Hello Genius people,
I am generating XML file using RecordListtoXML control. After generating xml, I am replacing few values in XML using Replace() function.
My generated structure is:
<LIABILITY ID="1" VALUE="ABC">
</LIABILITY>
<LIABILITY ID="2" VALUE="XYZ">
</LIABILITY>
<LIABILITY ID="3" VALUE="JKL">
</LIABILITY>
After replacement:
I am replacing </LIABILITY> by empty space i.e. ""
and after that ">" by " />"
It's giving me result like this:
<LIABILITY ID="1" VALUE="ABC" />
<LIABILITY ID="2" VALUE="XYZ" />
<LIABILITY ID="3" VALUE="JKL" />
I want to remove this line between two nodes.
i.e. my result should be like this
<LIABILITY ID="1" VALUE="ABC" />
<LIABILITY ID="2" VALUE="XYZ" />
<LIABILITY ID="3" VALUE="JKL" />
Is there any way to replace that empty line?
Please advice.
Thanks,
Suraj Borade
J.
Â
MVP
Why do you want to do that?
it's the same?
Suraj Borade
Hi J,
Thanks for the reply.
I need to send this generated XML to another server. So I want to format my generated XML. I don't want space between two lines. I
I think if there is space between two lines, another server will not be able to parse this XML.
João Rosado
Staff
But why are you replacing the </Liability> tags at all?
Explicit closing tags and Self-Closing tags are the same in XML ...any xml parser needs to support them.
Did you actually had problems with it or are just assuming the server won't work?
We can explain how to do the replacements you want
..but you shouldn't need any of them...
Regards,
João Rosado
Suraj Borade
Hi Joao,
Thanks for quick reply.
I am replacing Explicit closing tag because client want to see it as Self-Closing. So I want to format my XML output.
Suraj Borade
Hi Joao,
Can you please tell how to replace the empty line?
We need it now and can't push it any more since client wants to see formatted XML file.
Thanks a lot.
-- Suraj B
Pedro Gonçalves
Staff
Hi Suraj,
Have you tried the
regular expressions helper functions
? They should work for your scenario by replacing that exact closing tag with the closing tag characters you mentioned.
Regards,
Pedro
Suraj Borade
Thanks a lot Pedro.
Suraj Borade
Hi Pedro,
Sorry, I thought my issue was resolved but problem is still there.
I tried replacing result like this
Regex_Replace
(
GeneratedXML
,
"
\n
"
,
""
,
True
,
True
,
True
)
but it is treating "\n" as a string. Can you please suggest how should I set value of new line character in this replace?
Thanks a lot.
-- Suraj B
Pedro Gonçalves
Staff
Hello Suraj,
I'm not really sure about this, but "\n" doesn't seem to me a valid Regular Expression (Regex) for .NET
You are probably best served googling for
Regex .NET syntax
or in your specific case
regex to replace html tags
to which I found a few examples
here
and
here
. Probably these also need some tweaks.
Let me know how did it go, for you.
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
 Loading...