What are some best practices for handling line breaks in strings when reading data from XML files in PHP?

When reading data from XML files in PHP, it's important to handle line breaks in strings properly to avoid unexpected behavior. One common approach is to use the PHP function `trim()` to remove any leading or trailing whitespace, including line breaks. This ensures that the string is clean and can be processed correctly.

// Read XML data from a file
$xmlString = file_get_contents('data.xml');

// Load the XML string into an object
$xml = simplexml_load_string($xmlString);

// Access a specific element and remove line breaks using trim()
$elementValue = trim((string) $xml->element);

// Use the cleaned string as needed
echo $elementValue;