Friday 14 October 2016

Remove new line or space between tags in xml

<?php
$xml = '<Pages>
<Page Name="test">
<controls><test>this is a test.</test></controls>
</Page>
<page Name="User">
<controls><name>Sunil</name></controls>
</page>
</Pages>';
echo $xml;


$re = '/(?<=\>)(\r?\n)|(\r?\n)(?=\<\/)/';
$substring = '';

$xml = preg_replace($re, $substring, $xml);

echo "The result of the substitution is ".$xml;
?>


4 comments:

  1. Thanks for sharing the information.Impressive and i would like to share this with my friends
    Indian Cyber Army’s most awaited internship is live now. Summer Internship 2018 on “ Ethical hacking” and book your seats before it runs out.Candidates have to get themselves registered to be a part of this Internship program. Here internship will give you on-the-job experience, help you learn whether you and Cyber security industry are a good match and can provide you with valuable connections and references. Here interns are usually exposed to a wide variety of tasks and responsibilities which allows the intern to showcase their strengths by working on projects for various managers that work on different parts of Indian Cyber Army. Becoming a high performing intern is a fantastic way to improve your employment prospects. This internship can be a great way to get your foot in the door of success with a prestigious or desirable Organization.As career in ethical hacking is most in demand.

    ReplyDelete
  2. Nice Blog , This is what I exactly Looking for , Keep sharing more blog .
    PHP Database Programming in India

    ReplyDelete