How to get the name of an ID with PHP

Asked

Viewed 215 times

0

I am developing an application that reads files XML.

I can go all the way XML and take the data I want, but a need has arisen, all XML comes with a id different, a kind of access key, but this access key comes in a id.

How can I take this dice id and put into a variable?

MODELO DO ID NO XML

  • 2

    If you add your code the question becomes easier to help and be objective in the answer. Hug

  • worked out the solution?

  • Good evening friend, not I’m using another method other than simplexml_load, I’m trying to take your model and adapt with the method I’m using to try to get the ID value

  • with what I put below you can access what you need, including I put two examples. Then take a look

  • <?php //Instantiating OBJ $xml = new Domdocument(); //Taking TMP from FORM $file = $_XML[files'entXML']['tmp_name']; //Total of all XML $Vtotal = 0; //Total of all XML $totArchives=0; $files= $file; //Navigating Nodes(Nodes) foreach( $files as$files){ //Loading XML $xml ->load($files) or die("Error loading XML file"); //Enters inside the XML parent node $files = $xml->getelementsbytagname( "nfeProc" );

  • Basically this is the way that I am instantiating the XML and reading the Nodes, I already used the simplexml_load but I did not fit, I preferred to use the Domdocument library and access the XML via Load, so the way that made the examples I was not successful, I need to access the ID cross the method I’m using, anyway your examples were great

  • it is good to inform in the question the way you are working so we can be more objective and help you better. hug

  • True, missed in informing the method, Thanks hug !

Show 3 more comments

1 answer

1

Good afternoon,

you can access it as follows:

$domXml = simplexml_load_string($textoXml);
$nCh = preg_replace("/[^0-9]/","",$domXml->NFe->infNFe["Id"]);

note that the variable $domXml, must be or your string with XML.

Here is an example: An example with a file (obviously you will replace it with an xml you are using). And another example with a string. I copied an xml for a string.

<?php


    //Um Exemplo com arquivo
    $domXml = simplexml_load_file("31150201492857000139550010004869401111010024.xml"); 

    $textoXml = '<?xml version="1.0" encoding="UTF-8"?><nfeProc versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe"><NFe xmlns="http://www.portalfiscal.inf.br/nfe"><infNFe versao="2.00" Id="NFe31150201492857000139550010004869401111010024"><ide><cUF>31</cUF><cNF>11101002</cNF><natOp>VENDA DE MERCADORIAS SUJEITA AO REGIME DE S.T. - SUBSTITUIDO</natOp><indPag>1</indPag><mod>55</mod><serie>1</serie><nNF>486940</nNF><dEmi>2015-02-10</dEmi><dSaiEnt>2015-02-10</dSaiEnt><tpNF>1</tpNF><cMunFG>3154606</cMunFG><tpImp>1</tpImp><tpEmis>1</tpEmis><cDV>4</cDV><tpAmb>1</tpAmb><finNFe>1</finNFe><procEmi>0</procEmi><verProc>2.0</verProc></ide><emit><CNPJ>01492857000139</CNPJ><xNome>PACALUZ COMERCIO E LOGISTICA LTDA</xNome><xFant>PACALUZ COM.LOGISTICA-MATRIZ</xFant><enderEmit><xLgr>RUA ALEXANDRE BARRETO CAVALCANTE</xLgr><nro>64</nro><xBairro>ALTEROSA</xBairro><cMun>3154606</cMun><xMun>RIBEIRAO DAS NEVES</xMun><UF>MG</UF><CEP>33821105</CEP><cPais>1058</cPais><xPais>BRASIL</xPais><fone>3136269200</fone></enderEmit><IE>0629468770035</IE><CRT>3</CRT></emit><dest><CNPJ>11175063000103</CNPJ><xNome>GRACA ISABEL DE ARANTES REIS</xNome><enderDest><xLgr>RUA SEBASTIAO BRANDAO REIS</xLgr><nro>288</nro><xBairro>CENTRO</xBairro><cMun>3135902</cMun><xMun>JESUANIA</xMun><UF>MG</UF><CEP>37485000</CEP><cPais>1058</cPais><xPais>BRASIL</xPais><fone>3532731298</fone></enderDest><IE>0014223240030</IE></dest><entrega><CNPJ>11175063000103</CNPJ><xLgr>RUA SEBASTIAO BRANDAO REIS</xLgr><nro>288</nro><xBairro>CENTRO</xBairro><cMun>3135902</cMun><xMun>JESUANIA</xMun><UF>MG</UF></entrega><det nItem="1"><prod><cProd>5440</cProd><cEAN>7891035215001</cEAN><xProd>VEJA LIMP.PESADA 500ML TRADICIONAL</xProd><NCM>34022000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>12.0000</qCom><vUnCom>3.5895000000</vUnCom><vProd>43.07</vProd><cEANTrib>7891035215001</cEANTrib><uTrib>UN</uTrib><qTrib>12.0000</qTrib><vUnTrib>3.5895000000</vUnTrib><vOutro>0.41</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>12.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>43.07</vBC><pPIS>1.65</pPIS><vPIS>0.71</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>43.07</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>3.27</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="2"><prod><cProd>9825</cProd><cEAN>7891035800214</cEAN><xProd>VEJA MULTIUSO 500ML TRADIC.L500P450</xProd><NCM>34022000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>24.0000</qCom><vUnCom>2.3580000000</vUnCom><vProd>56.59</vProd><cEANTrib>7891035800214</cEANTrib><uTrib>UN</uTrib><qTrib>24.0000</qTrib><vUnTrib>2.3580000000</vUnTrib><vOutro>0.64</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>24.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>56.59</vBC><pPIS>1.65</pPIS><vPIS>0.93</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>56.59</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>4.30</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="3"><prod><cProd>6734</cProd><cEAN>7891035210334</cEAN><xProd>VEJA MULTIUSO 500ML LAVANDA</xProd><NCM>34022000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>12.0000</qCom><vUnCom>2.4267000000</vUnCom><vProd>29.12</vProd><cEANTrib>7891035210334</cEANTrib><uTrib>UN</uTrib><qTrib>12.0000</qTrib><vUnTrib>2.4267000000</vUnTrib><vOutro>0.27</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>12.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>29.12</vBC><pPIS>1.65</pPIS><vPIS>0.48</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>29.12</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>2.21</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="4"><prod><cProd>5430</cProd><cEAN>7891035209000</cEAN><xProd>VEJA MULTIUSO 500ML CAMPESTRE</xProd><NCM>34022000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>12.0000</qCom><vUnCom>2.4267000000</vUnCom><vProd>29.12</vProd><cEANTrib>7891035209000</cEANTrib><uTrib>UN</uTrib><qTrib>12.0000</qTrib><vUnTrib>2.4267000000</vUnTrib><vOutro>0.27</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>12.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>29.12</vBC><pPIS>1.65</pPIS><vPIS>0.48</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>29.12</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>2.21</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="5"><prod><cProd>5337</cProd><cEAN>7891035250002</cEAN><xProd>VEJA LIMP.PESADA 500ML CLORO</xProd><NCM>34022000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>12.0000</qCom><vUnCom>3.5895000000</vUnCom><vProd>43.07</vProd><cEANTrib>7891035250002</cEANTrib><uTrib>UN</uTrib><qTrib>12.0000</qTrib><vUnTrib>3.5895000000</vUnTrib><vOutro>0.41</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>12.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>43.07</vBC><pPIS>1.65</pPIS><vPIS>0.71</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>43.07</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>3.27</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="6"><prod><cProd>8312</cProd><cEAN>7891035537974</cEAN><xProd>BOM AR AERO 360ML VIDA DOCE</xProd><NCM>33074900</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>6.7115000000</vUnCom><vProd>40.27</vProd><cEANTrib>7891035537974</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>6.7115000000</vUnTrib><vOutro>0.38</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISNT><CST>07</CST></PISNT></PIS><COFINS><COFINSNT><CST>07</CST></COFINSNT></COFINS></imposto></det><det nItem="7"><prod><cProd>5473</cProd><cEAN>7891035500008</cEAN><xProd>LUSTRA MOV.POLIF.200ML JASMIM</xProd><NCM>34052000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>4.4988000000</vUnCom><vProd>26.99</vProd><cEANTrib>7891035500008</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>4.4988000000</vUnTrib><vOutro>0.25</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>26.99</vBC><pPIS>1.65</pPIS><vPIS>0.45</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>26.99</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>2.05</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="8"><prod><cProd>5476</cProd><cEAN>7891035502200</cEAN><xProd>LUSTRA MOV.POLIF.200ML LAVANDA</xProd><NCM>34052000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>4.4988000000</vUnCom><vProd>26.99</vProd><cEANTrib>7891035502200</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>4.4988000000</vUnTrib><vOutro>0.25</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>26.99</vBC><pPIS>1.65</pPIS><vPIS>0.45</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>26.99</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>2.05</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="9"><prod><cProd>5399</cProd><cEAN>7891035017001</cEAN><xProd>VANISH RESOLV 500ML</xProd><NCM>34022000</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>6.3848000000</vUnCom><vProd>38.31</vProd><cEANTrib>7891035017001</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>6.3848000000</vUnTrib><vOutro>0.36</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>38.31</vBC><pPIS>1.65</pPIS><vPIS>0.63</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>38.31</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>2.91</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="10"><prod><cProd>6625</cProd><cEAN>7891035024924</cEAN><xProd>SBP AERO M.INSET.300ML CITRONELA</xProd><NCM>38089119</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>8.0000</qCom><vUnCom>6.3767000000</vUnCom><vProd>51.01</vProd><cEANTrib>7891035024924</cEANTrib><uTrib>UN</uTrib><qTrib>8.0000</qTrib><vUnTrib>6.3767000000</vUnTrib><vOutro>0.48</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>8.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>51.01</vBC><pPIS>1.65</pPIS><vPIS>0.84</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>51.01</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>3.88</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="11"><prod><cProd>6939</cProd><cEAN>7891035024986</cEAN><xProd>SBP AERO M.INSET.300ML EUCALIPTO</xProd><NCM>38089119</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>8.0000</qCom><vUnCom>6.3767000000</vUnCom><vProd>51.01</vProd><cEANTrib>7891035024986</cEANTrib><uTrib>UN</uTrib><qTrib>8.0000</qTrib><vUnTrib>6.3767000000</vUnTrib><vOutro>0.48</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>8.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>51.01</vBC><pPIS>1.65</pPIS><vPIS>0.84</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>51.01</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>3.88</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="12"><prod><cProd>312</cProd><cEAN>7891035612060</cEAN><xProd>MORTEIN RODOX M.BARATA 300ML</xProd><NCM>38089119</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>7.8293000000</vUnCom><vProd>46.98</vProd><cEANTrib>7891035612060</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>7.8293000000</vUnTrib><vOutro>0.44</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>46.98</vBC><pPIS>1.65</pPIS><vPIS>0.78</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>46.98</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>3.57</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="13"><prod><cProd>7399</cProd><cEAN>17896016603348</cEAN><xProd>AGUA COCO DUCOCO 27X200ML TP</xProd><NCM>20098990</NCM><CFOP>5405</CFOP><uCom>CX</uCom><qCom>1.0000</qCom><vUnCom>37.2340000000</vUnCom><vProd>37.23</vProd><cEANTrib>17896016603348</cEANTrib><uTrib>CX</uTrib><qTrib>1.0000</qTrib><vUnTrib>37.2340000000</vUnTrib><vOutro>0.35</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>1.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISAliq><CST>01</CST><vBC>37.23</vBC><pPIS>1.65</pPIS><vPIS>0.61</vPIS></PISAliq></PIS><COFINS><COFINSAliq><CST>01</CST><vBC>37.23</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>2.83</vCOFINS></COFINSAliq></COFINS></imposto></det><det nItem="14"><prod><cProd>9508</cProd><cEAN>7890704806441</cEAN><xProd>SAB.NIVEA 90GR ERVA DOCE</xProd><NCM>34011190</NCM><EXTIPI>01</EXTIPI><CFOP>5405</CFOP><uCom>UN</uCom><qCom>48.0000</qCom><vUnCom>0.8899000000</vUnCom><vProd>42.72</vProd><cEANTrib>7890704806441</cEANTrib><uTrib>UN</uTrib><qTrib>48.0000</qTrib><vUnTrib>0.8899000000</vUnTrib><vOutro>0.40</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>48.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISNT><CST>07</CST></PISNT></PIS><COFINS><COFINSNT><CST>07</CST></COFINSNT></COFINS></imposto></det><det nItem="15"><prod><cProd>9475</cProd><cEAN>4005900036728</cEAN><xProd>DESOD.NIVEA AERO 150ML INVBL-WT.PWR</xProd><NCM>33072010</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>8.2015000000</vUnCom><vProd>49.21</vProd><cEANTrib>4005900036728</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>8.2015000000</vUnTrib><vOutro>0.47</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISNT><CST>07</CST></PISNT></PIS><COFINS><COFINSNT><CST>07</CST></COFINSNT></COFINS></imposto></det><det nItem="16"><prod><cProd>9473</cProd><cEAN>4005900036667</cEAN><xProd>DESOD.NIVEA AERO 150ML INVBL-WT.CLR</xProd><NCM>33072010</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>8.2015000000</vUnCom><vProd>49.21</vProd><cEANTrib>4005900036667</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>8.2015000000</vUnTrib><vOutro>0.47</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISNT><CST>07</CST></PISNT></PIS><COFINS><COFINSNT><CST>07</CST></COFINSNT></COFINS></imposto></det><det nItem="17"><prod><cProd>9474</cProd><cEAN>4005900036704</cEAN><xProd>DESOD.NIVEA ROLL-0N 50ML INVBLC-WHT.CLR</xProd><NCM>33072010</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>4.7516000000</vUnCom><vProd>28.51</vProd><cEANTrib>4005900036704</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>4.7516000000</vUnTrib><vOutro>0.27</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISNT><CST>07</CST></PISNT></PIS><COFINS><COFINSNT><CST>07</CST></COFINSNT></COFINS></imposto></det><det nItem="18"><prod><cProd>9476</cProd><cEAN>4005900036759</cEAN><xProd>DESOD.NIVEA ROLL-0N 50ML INVBLC-WHT.PWR</xProd><NCM>33072010</NCM><CFOP>5405</CFOP><uCom>UN</uCom><qCom>6.0000</qCom><vUnCom>4.7516000000</vUnCom><vProd>28.51</vProd><cEANTrib>4005900036759</cEANTrib><uTrib>UN</uTrib><qTrib>6.0000</qTrib><vUnTrib>4.7516000000</vUnTrib><vOutro>0.27</vOutro><indTot>1</indTot><xPed>67901697</xPed></prod><imposto><ICMS><ICMS60><orig>0</orig><CST>60</CST></ICMS60></ICMS><IPI><cEnq>999</cEnq><IPITrib><CST>99</CST><qUnid>6.0000</qUnid><vUnid>0.0000</vUnid><vIPI>0.00</vIPI></IPITrib></IPI><PIS><PISNT><CST>07</CST></PISNT></PIS><COFINS><COFINSNT><CST>07</CST></COFINSNT></COFINS></imposto></det><total><ICMSTot><vBC>0.00</vBC><vICMS>0.00</vICMS><vBCST>0.00</vBCST><vST>0.00</vST><vProd>717.92</vProd><vFrete>0.00</vFrete><vSeg>0.00</vSeg><vDesc>0.00</vDesc><vII>0.00</vII><vIPI>0.00</vIPI><vPIS>7.91</vPIS><vCOFINS>36.43</vCOFINS><vOutro>6.87</vOutro><vNF>724.79</vNF></ICMSTot></total><transp><modFrete>0</modFrete><transporta><CNPJ>21110956000205</CNPJ><xNome>COOPTRANSLOG COOP. DE TRANSP. LOG. E DIST. ROD. DE CARGAS</xNome><xEnder>R. MARIA JOSE CARDOSO, 195 - CENTRO</xEnder><xMun>SARZEDO</xMun><UF>MG</UF></transporta><veicTransp><placa>KAZ2606</placa><UF>MG</UF></veicTransp><vol><qVol>8</qVol><pesoL>66.879</pesoL><pesoB>68.665</pesoB></vol></transp><cobr><dup><nDup>486940 - 1</nDup><dVenc>2015-02-24</dVenc><vDup>241.61</vDup></dup><dup><nDup>486940 - 2</nDup><dVenc>2015-03-03</dVenc><vDup>241.59</vDup></dup><dup><nDup>486940 - 3</nDup><dVenc>2015-03-10</dVenc><vDup>241.59</vDup></dup></cobr><infAdic><infCpl>ST JA RETIDO ART. 37 INC. II PART. I DO ANEXO XV ST JA RETIDO ART. 37 INC. II PART. I DO ANEXO XV - ; FAVOR CONFERIR MERCADORIA NO ATO DA ENTREGA. NAO ACEITAREMOS RECLAMACOES POSTERIORES. PRAZO DE VALIDADE 8 (OITO) DIAS. REGIME ESPECIAL/PTA NR. 16.000423503-41-SEF/MG; COD.VENDEDOR: 67 VENDEDOR: ROBERSON E LAGE REP. ME-67 ROTA: 5; FORMA PAGAMENTO: BANCO DO BRASIL - COB.BANCARIA - 03/14-21-28; TRANSACAO: 1223515; BASE ST: 805,37 ICMS ST: 90,15; NUM.PEDIDO: 67901697 NUM. CARGA: 21690 NUM. BOX: 9</infCpl></infAdic></infNFe><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><Reference URI="#NFe31150201492857000139550010004869401111010024"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>X2PFqV9jkJyX20LV3Yh3bIcSOwA=</DigestValue></Reference></SignedInfo><SignatureValue>X2PFqV9jkJyX20LV3Yh3bIcSOwA=</SignatureValue><KeyInfo><X509Data><X509Certificate>X2PFqV9jkJyX20LV3Yh3bIcSOwA=</X509Certificate></X509Data></KeyInfo></Signature></NFe><protNFe versao="2.00"><infProt><tpAmb>1</tpAmb><verAplic>2.0</verAplic><chNFe>31150201492857000139550010004869401111010024</chNFe><dhRecbto>2015-02-10T14:11:10</dhRecbto><nProt>131151670420064</nProt><digVal>X2PFqV9jkJyX20LV3Yh3bIcSOwA=</digVal><cStat>100</cStat><xMotivo>Autorizado o uso da NF-e</xMotivo></infProt></protNFe></nfeProc>';

    //Um Exemplo com String
    $domXml = simplexml_load_string($textoXml);

    $nCh = $domXml->NFe->infNFe["Id"];

    echo $nCh;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.