PHP - How to get the correct XPath

#40096
Posted: 01/09/2018 15:44:47
by Alex Beltrán (Basic support level)
Joined: 12/27/2017
Posts: 11

I need to sign different xml types: Invoice, CreditNote and DebitNote, and this different types are at te top of each xml:
<fe:Invoice
<fe:CreditNote
<fe:DebitNote

How can i know which kind of xml i'm going to sign?

i'm loading the XML files with this code:
Code
$xmlDocument = new TElXMLDOMDocument();
$xmlDocument->LoadFromFile($file);


I've tried with several methods of TElXMLDOMDocument whitout any success, and all this is to use the same PHP script to sign any of those xml, because my script adds Namespaces to select the specific node where i need to place the signature:

Code
$nsMap->AddNamespace('ext', 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2');
$nsMap->AddNamespace('fe', 'http://xxxxxx/yyyyyyy/zzzzzzz')
$nodeSet = $xmlDocument->SelectNodes('/fe:Invoice/etc/etc/etc/etc', $nsMap);


or

Code
$nsMap->AddNamespace('ext', 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2');
$nsMap->AddNamespace('fe', 'http://xxxxxx/yyyyyyy/zzzzzzz')
$nodeSet = $xmlDocument->SelectNodes('/fe:DebitNote/etc/etc/etc/etc', $nsMap);


or

Code
$nsMap->AddNamespace('ext', 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2');
$nsMap->AddNamespace('fe', 'http://xxxxxx/yyyyyyy/zzzzzzz')
$nodeSet = $xmlDocument->SelectNodes('/fe:CreditNote/etc/etc/etc/etc', $nsMap);


See the small change at third line in the above codes.

Thank you in advance.
#40097
Posted: 01/09/2018 15:53:14
by Alex Beltrán (Basic support level)
Joined: 12/27/2017
Posts: 11

Solved!!!!

With this piece of code i can get the XML type:

Code
$xmlDocument->DocumentElement->get_LocalName()


Thank you...

Reply

Statistics

Topic viewed 175 times

Number of guests: 1, registered members: 0, in total hidden: 0





Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!