SELECT
CAST(REPLACE(CAST(DsXML as Nvarchar(Max)),' xmlns="http://www.portalfiscal.inf.br/nfe"','') as xml).value('(/nfeProc/NFe/infNFe/transp/vol/qVol/node())[1]', 'int') as [qVol]
FROM SPDNFE
WHERE CdIdNFe = 'NFe13161203976141000132550030000435291400513027'
By this SQL query within a php script, I get the following error.
Parse error: syntax error, unexpected 'xmlns' (T_STRING)
As it is in PHP.
public function teste($teste) {
$sql = 'SELECT
CAST(REPLACE(CAST(DsXML as Nvarchar(Max)),' xmlns="http://www.portalfiscal.inf.br/nfe"','') as xml).value('(/nfeProc/NFe/infNFe/transp/vol/qVol/node())[1]', 'int') as [qVol]
FROM SPDNFE
WHERE CdIdNFe = '$teste'';
$results = array();
$stmt = $this->conn->prepare($sql);
$stmt->execute();
if ($stmt) {
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
$info = new Model();
$info->getQVol($row->qVol);
$results[] = $info;
}
}
return $results;
}