protected function loadIncludes($xmlPath, $xmlString)
    {
        $m = null;
        if (preg_match_all("/\<include\s*href\=\"([^\"]+)\".*?\/\>/si", $xmlString, $m, PREG_SET_ORDER) !== false) {
            foreach ($m as $match) {
                $includeFile = rtrim($xmlPath, '/').'/'.$match[1];
                if (file_exists($includeFile)) {
                    $includeString = file_get_contents($includeFile);
                    $includeString = $this->loadIncludes(dirname($includeFile), $includeString);
                    $xmlString = str_replace($match[0], $includeString, $xmlString);
                } else {
                    throw new Exception("XML include file not found: {$includeFile}");
                }
            }
        }

        return $xmlString;
    }