Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing xml without namespace
    primarykey
    data
    text
    <p>I have a parsing problem that appears when I try to parse from a String, containg a xml, to a org.w3c.dom.Document.</p> <p>Here is a example of a xml String that i'm trying to parse:</p> <pre><code>&lt;enviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00"&gt; &lt;idLote&gt;123&lt;/idLote&gt; &lt;NFe xmlns="http://www.portalfiscal.inf.br/nfe"&gt; ... &lt;/NFe&gt; &lt;/enviNFe&gt; </code></pre> <p>The problem is, that after que String had been parsed, by the following code:</p> <pre><code>private Document documentFactory(String xml) throws SAXException, IOException, ParserConfigurationException, DocumentException, TransformerException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document document = factory.newDocumentBuilder().parse( new ByteArrayInputStream(xml.getBytes())); return document; } </code></pre> <p>The tag NFe loads without the namespace (xmlns="http://www.portalfiscal.inf.br/nfe")</p> <p>I want to know why this happens, and what I could do to solve this.</p> <p>Any help will be great. Thanks, and sorry for my english.</p> <p>------EDIT---- For better understanding:</p> <p>This xml will be signed right after de parsing, and will be sent to a Government's server(Brazil). After this, I do another request to this server, to verify if it was processed or not. If it was, I will get a positive response in case of any error. The first problem I had, was that the xml was malformed. This happened because I was sending the xml without that namespace in the tag NFe. To solve this I added it(namespace) right in the File, after the xml had being signed. This problem in fact had been solved, but another occurred: the difference in the signature. Because I signs the xml without the namespace, and send with it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload