使用replaceChild php DOM替换TextNode

I have this XML file and I need to replace te value of qteStock using the php DOM,but I still can't get the concept.Can anyone help me please?

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="Marque.xsl" ?>
<Marques xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Marques.xsd">    
<Marque>
   <codeMarque>00003</codeMarque>
   <nomMarque>Diesel</nomMarque>
   <paysOrigine>USA</paysOrigine>
   <qteStock>50</qteStock>
   <qteLimite>5</qteLimite>
</Marque>
</Marques>

This is the php code I've been trying to manipulate:

<?php
$marque=$_POST['nomMarque'];
$qte=$_POST['qte'];

$xmlstring = 'entities/Marques.xml';
$dom = new DOMDocument; 
$dom->load($xmlstring);

$xpath = new DOMXPath($dom);

$query = "//Marque[nomMarque='".$marque."']/qteStock";
$qteStock = $xpath->query($query);

$query = "//Marque[nomMarque='".$marque."']/qteLimite";
$qteLimite = $xpath->query($query);

$nouvelleQuantite = $qteStock->item(0)->nodeValue-$qte ;
$newQuantity = $dom->createTextNode($nouvelleQuantite);

$return = ($qteStock->replaceChild($newQuantity,$qteStock);
$dom->save('entities/Marques.xml');
?>

You can set the nodeValue property of the element node - integers do not need escaping in XML. If you need to write text that could contain &, set the nodeValue to an empty string (deletes all child nodes) and insert a new text node.

$changeValue = 5;

$dom = new DOMDocument();
$dom->loadXml($xml);
$xpath = new DOMXpath($dom);

$nodes = $xpath->evaluate('/Marques/Marque[1]/qteStock');
// node found?
if ($nodes->length > 0) {
  $stock = $nodes->item(0);
  $newValue = $stock->nodeValue - $changeValue;
  // just set the content (an int does not need any escaping)
  $stock->nodeValue = (int)$newValue;
}

echo $dom->saveXml();

Demo: https://eval.in/149098