2 years ago

#73460

test-img

Mirza Hasnat

How to write xml file without encoding utf-8 to HTML entity in PHP DOMDocument?

I'm creating hacking lab(XML injection) and i want to save the text as it is

for example:

input text: tryingtoattack"

but DOMDocument encoding the quotes(or any spacial char) like this

output text: tryingtoattac"

so my question is how can i write xml file without encoding the quotes(or any other char)

here's my code

    if(isset($_GET['name']) && isset($_GET['price'])){
        print_r($_GET['name']);
        $addproduct = new DOMDocument('1.0','utf-8');
        $addproduct->load('./usres.xml');
        $products = $addproduct->getElementsByTagName('product')->item(0)->parentNode;


        $product = $addproduct->createElement('product');
        $product->setAttribute('product-name',$_GET['name']);
        $name = $addproduct->createElement('name', "".$_GET['name']."");
        $product->appendChild($name);
        $price = $addproduct->createElement('price', $_GET['price']);
        $product->appendChild($price);
        
        $products->insertBefore($product);
        $addproduct->save('./usres.xml');
    }

php

domdocument

autoencoder

xml-attribute

0 Answers

Your Answer

Accepted video resources