J'ai essayé tous les moyens possibles pour supprimer les xmlns vides des balises. Veuillez m'aider à résoudre ce problème.
$XMLDoc = new DOMDocument('1.0', 'UTF-8');
$XMLDoc->preserveWhiteSpace = false;
$XMLDoc->formatOutput = true;
$soap = $XMLDoc->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'soap:Envelope');
$XMLDoc->appendChild($soap);
$soap->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$soap->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
$soap->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:soap', 'http://schemas.xmlsoap.org/soap/envelope/');
$body = $XMLDoc->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'soap:Body');
$XMLDoc->appendChild($body);
include 'DBDetails.php';
$XMlQuery="SELECT `First_Name`, `Last_Name`, `Email`, `Pan_No`, `Res_address`, `Res_address2`, `Res_address3`, `Resi_type`, `Mobile`, `Res_City`, `Resi_City_other`, `Resi_City_other1`, `res_pin`, `Company_name`, `DateOfBirth`, `Designation`, `Emp_type`, `Monthly_income`, `card_held`, `Source_code`, `Promo_code`, `LEAD_DATE_TIME`, `PRODUCT_APPLIED_FOR`, `existingcust`, `LoanAmt`, `YrsinEmp`, `emi_paid`, `car_make`, `car_model`, `TypeOfLoan`, `IP_Address`, `Indigo_UniqueKey`, `Indigo_RequestFromYesNo` FROM `webservice` WHERE `Source_code` LIKE '$Sourcecode'";
$rowcount=-1;
if($result=mysqli_query($conn,$XMlQuery)) {
$rowcount=mysqli_num_rows($result);
}
if($rowcount>0){
$StockCount=-1;
$rootElement = $XMLDoc->createElement('AddDetails');
$rootNode=$body->appendChild($rootElement);
while($result_array = $result->fetch_assoc()) {
$StockCount++;
foreach($result_array as $key => $value) {
$value=trim($value);
if($value=="NULL" || $value=="" ||$value==-1){
$value="";
}
$rootNode->appendChild($XMLDoc->createElement($key,$value));
}
}
mysqli_close($conn);
}
$XSLDoc = new DOMDocument('1.0', 'UTF-8');
$xslstr = '<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output version="1.0" encoding="UTF-8" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:apply-templates select="@*|node()" />
</xsl:template>
<xsl:template match="AddDetails">
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddDetails xmlns="http://tempuri.org/">
<xsl:copy-of select="*" />
</AddDetails>
</soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:transform>';
$XSLDoc->loadXML($xslstr);
$proc = new XSLTProcessor;
$proc->importStyleSheet($XSLDoc);
$newXML = $proc->transformToXML($XMLDoc);
echo $newXML;
Il en résulte que
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddDetails xmlns="http://tempuri.org/">
<First_Name xmlns="">TestFName</First_Name>
<Last_Name xmlns="">TestLName</Last_Name>
<Email xmlns="">test@gfdg.co.in</Email>
</AddDetails>
</soap:Body>
</soap:Envelope>
Je voudrais générer le XML comme ceci
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddDetails xmlns="http://tempuri.org/">
<First_Name>TestFName</First_Name>
<Last_Name>TestLName</Last_Name>
<Email>test@gfdg.co.in</Email>
</AddDetails>
</soap:Body>
</soap:Envelope>
S'il vous plaît aidez-moi. Je veux générer le code sans xmlns vide.