I have an xml file containing 6000 element like LastName and FirstName.
I need to remove new line inside element value.
Input:
<info>
<LastName>
HOOVER
</LastName>
</info>
Output:
<info>
<LastName>
HOOVER
</LastName>
</info>
I’ve tried preg_replace and str_replace for space and \n, \t, \r and failed.
Since you are working with XML, you should also use one of the XML extensions PHP has to offer. The example below uses DOM and XPath to find all the text nodes in your XML document and
trimthem.Input:
Code:
Output: