I have this XML:
<?xml version="1.0" encoding="UTF-8" ?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="3.3" Serie="NG" Folio="55" Fecha="2017-08-02T20:08:58" FormaPago="99" SubTotal="5861.73" Descuento="778.38" Moneda="MXN" Total="5083.35" TipoDeComprobante="N" MetodoPago="PUE" LugarExpedicion="08400" Sello="yAfYBR0/bvvFgq/hNL+DSTTPt+kNtsE3DzxagXvG0M/alfaUrjp73IySCEBHIeo4nNF4uoscqnRoIowwfQPnNwC4LL6iD77rfykF2hq+i6VzqAlvbx0aawZUAcJpjNVWyS3zjfa3rYeU1TpNBrhSuU8r+4BoBz3jr1pB7yyCIm4JbwzNqy0TvTjD1XXnpy6v74+eqIoZqWZoi3CyiCqMS2B3FEfDMiXTfVlZ/3/evLYc5WvFPpBsm61I+SBID/rHhJvLQLjJDUX7Myt177N41xptITkIKQCJAIV6XN7mRGJTHKA3h3F7tSZaei8+LeONO9ZtlUZGw4dzLhrpNk/tuA==" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd">
<cfdi:Emisor Rfc="BBBBBB" Nombre="S.A. de C.V." RegimenFiscal="601" />
<cfdi:Receptor Rfc="AAAAAAAA" Nombre="AZUCENA SAN " UsoCFDI="P01" />
<cfdi:Conceptos>
<cfdi:Concepto ClaveProdServ="84111505" Cantidad="1" ClaveUnidad="ACT" Descripcion="Pago de nómina" ValorUnitario="5861.73" Importe="5861.73" Descuento="778.38" />
</cfdi:Conceptos>
<cfdi:Complemento>
<nomina12:Nomina xmlns:nomina12="http://www.sat.gob.mx/nomina12" Version="1.2" TipoNomina="O" FechaPago="2017-07-16" FechaInicialPago="2017-07-01" FechaFinalPago="2017-08-15" NumDiasPagados="15.000" TotalPercepciones="5861.73" TotalDeducciones="778.38" xsi:schemaLocation="http://www.sat.gob.mx/nomina12 http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsd">
<nomina12:Emisor RegistroPatronal="Y6844621109" />
<nomina12:Receptor Curp="SASA850203MDFNNZ06" NumSeguridadSocial="39058519115" FechaInicioRelLaboral="2012-09-14" Antigüedad="P254W" TipoContrato="01" Sindicalizado="No" TipoJornada="03" TipoRegimen="02" NumEmpleado="073" Departamento="VENTAS" Puesto="GERENTE TIENDAS" RiesgoPuesto="1" PeriodicidadPago="04" SalarioBaseCotApor="183.33" SalarioDiarioIntegrado="356.57" ClaveEntFed="DIF" />
<nomina12:Percepciones TotalSueldos="5861.73" TotalGravado="5089.21" TotalExento="772.52">
<nomina12:Percepcion TipoPercepcion="001" Clave="0001" Concepto="Sueldos" ImporteGravado="1026.69" ImporteExento="0.00" />
<nomina12:Percepcion TipoPercepcion="020" Clave="0008" Concepto="Prima dominical" ImporteGravado="0" ImporteExento="78.36" />
<nomina12:Percepcion TipoPercepcion="001" Clave="0020" Concepto="Vacaciones" ImporteGravado="1466.69" ImporteExento="0" />
<nomina12:Percepcion TipoPercepcion="021" Clave="0009" Concepto="Prima Vacacional" ImporteGravado="0" ImporteExento="458.33" />
<nomina12:Percepcion TipoPercepcion="038" Clave="0022" Concepto="Bonos" ImporteGravado="1000" ImporteExento="0" />
<nomina12:Percepcion TipoPercepcion="028" Clave="0010" Concepto="Comisiones" ImporteGravado="1360" ImporteExento="0" />
<nomina12:Percepcion TipoPercepcion="019" Clave="0007" Concepto="Horas extras" ImporteGravado="235.83" ImporteExento="235.83">
<nomina12:HorasExtra Dias="2" TipoHoras="01" HorasExtra="2" ImportePagado="235.83" />
<nomina12:HorasExtra Dias="1" TipoHoras="02" HorasExtra="1" ImportePagado="235.83" />
</nomina12:Percepcion>
</nomina12:Percepciones>
<nomina12:Deducciones TotalOtrasDeducciones="122.73" TotalImpuestosRetenidos="655.65">
<nomina12:Deduccion TipoDeduccion="002" Clave="0013" Concepto="ISR" Importe="655.65" />
<nomina12:Deduccion TipoDeduccion="001" Clave="0012" Concepto="IMSS" Importe="122.73" />
</nomina12:Deducciones>
</nomina12:Nomina>
<tfd:TimbreFiscalDigital xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital" xsi:schemaLocation="http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/sitio_internet/cfd/timbrefiscaldigital/TimbreFiscalDigitalv11.xsd" Version="1.1" UUID="2A73927D-7E57-40C7-9A8B-2E062560AC9E" FechaTimbrado="2017-08-02T19:52:07" SelloCFD="yAfYBR0/bvvFgq/hNL+DSTTPt+kNtsE3DzxagXvG0M/alfaUrjp73IySCEBHIeo4nNF4uoscqnRoIowwfQPnNwC4LL6iD77rfykF2hq+i6VzqAlvbx0aawZUAcJpjNVWyS3zjfa3rYeU1TpNBrhSuU8r+4BoBz3jr1pB7yyCIm4JbwzNqy0TvTjD1XXnpy6v74+eqIoZqWZoi3CyiCqMS2B3FEfDMiXTfVlZ/3/evLYc5WvFPpBsm61I+SBID/rHhJvLQLjJDUX7Myt177N41xptITkIKQCJAIV6XN7mRGJTHKA3h3F7tSZaei8+LeONO9ZtlUZGw4dzLhrpNk/tuA==" NoCertificadoSAT="20001000000300022323" SelloSAT="FXfgRBNhWla+53sM4eGnMFbbmQFb6EIaWMt3GMaqXJn9XPxQ5DVNuz7oTJ+yUZV0ObM5myqzzsI4Zvx3g==" RfcProvCertif="EME000602QR9" />
</cfdi:Complemento>
</cfdi:Comprobante>
And I need to get the values of some attributes, I can get attributes from the node cfdi:Comprobante, but when I try to read an attribute from tfd:TimbreFiscalDigital I get object reference not set to an instance of an object.
Here is the code I'm using:
Dim doc As XmlDocument = New XmlDocument()
doc.Load("C:\Users\s_osr\Desktop\EjemplosCFDINomina12\HorasExtras\SIGN_XML_COMPROBANTE_3_0.xml")
Dim managerdoc As XmlNamespaceManager = New XmlNamespaceManager(doc.NameTable)
managerdoc.AddNamespace("cfdi", doc.DocumentElement.NamespaceURI)
managerdoc.AddNamespace("tfd", doc.DocumentElement.NamespaceURI)
Dim Sello As String = doc.SelectSingleNode("/cfdi:Comprobante/#Sello", managerdoc).InnerText
Dim SelloSat As String = doc.SelectSingleNode("/cfdi:Comprobante/cfdi:Complemento/tfd:TimbreFiscalDigital/#SelloSAT", managerdoc).InnerText
Sello is working, but I can´t get SelloSAT.
UPDATE:
Thanks to #Kaiido for the solution, the uri string for the second namespace:
managerdoc.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
Related
From the below XML log, I have requirement to extract phoneNumber only <json:string name="phoneNumber">9480562628</json:string>. Can someone help in this??
<Input>
<Header>
<User-Agent>android;11;4.27.0;samsung_SM-A205F</User-Agent>
<Date>Sun, 09 Oct 2022 21:59:08 GMT</Date>
<Username />
<UserInfo />
<Location>1wIRSNscfkI0qragmfshMiG189qgAf/PumlP3DTbgN4=</Location>
<AAAUN>SFASJNF3U6375H7D1Y4XWJDZ</AAAUN>
<Authorization>WS androidDove:ri6/G20ZNX+bsNyX8GUEB4vSMS4=</Authorization>
<h>test</h>
<Accept-Language>en</Accept-Language>
<Test>false</Test>
<Content-Type>application/json; charset=UTF-8</Content-Type>
<Content-Length>75</Content-Length>
<Host>com.in</Host>
<Accept-Encoding>gzip</Accept-Encoding>
<X-Forwarded-For>0.0.0.0, 0.0.0.0</X-Forwarded-For>
<X-APIRP-ID>0.0.0.0</X-APIRP-ID>
<Via>1.1 69WC0-</Via>
<X-Client-IP>0.0.0.0.</X-Client-IP>
<X-Global-Transaction-ID>RU44D1I3S40ZBVLMQHHUZSB1QOH1HEWO700LZQLB5WR8IGZYU4</X-Global-Transaction-ID>
</Header>
<X />
<URI>/esb/crs2/public/Login</URI>
<ServiceName>PUBLICPOSTOTPLOGIN</ServiceName>
<PrimaryKey />
<Parameters>
<Parameter1 />
<Parameter2 />
<Parameter3 />
<Parameter4 />
</Parameters>
<Body>
<json:object xmlns:json="http://www.ibm.com/" xmlns:xsi="http://www.w3.org/" xsi:schemaLocation="http://www.datapower.com">
<json:string name="phoneNumber">9480562628</json:string>
</json:object>
</Body>
<standardRule>Y</standardRule>
<TRANSACTION_ID>SFASJNF3U6375H7D1Y4XWJDZ</TRANSACTION_ID>
<TRANSACTION_NAME>Login</TRANSACTION_NAME>
<JSON_Body>{ "phoneNumber":"9480562628" }</JSON_Body>
</Input>
Expected Result:
9480562628
This statement got the result as expected. :)
extractvalue(xmltype(x.xml_request), '(/Input//phoneNumber)[1]/text()')
|| ' '|| extractvalue(xmltype(x.xml_request), '(/Input/Body//*[#name="phoneNumber"])[1]/text()') AS "phoneNumber_"
Use XMLTABLE and specify the XMLNAMESPACES:
SELECT x.*
FROM table_name t
CROSS APPLY XMLTABLE(
XMLNAMESPACES('http://www.ibm.com/' AS "json", 'http://www.w3.org/' AS "xsi"),
'/Input'
PASSING XMLTYPE(t.xml)
COLUMNS
phonenumber VARCHAR2(20) PATH './Body/json:object/json:string[#name="phoneNumber"]'
) x
Which, for your sample data:
CREATE TABLE table_name (xml CLOB);
INSERT INTO table_name (xml) VALUES ('<Input>
<Header>
<User-Agent>android;11;4.27.0;samsung_SM-A205F</User-Agent>
<Date>Sun, 09 Oct 2022 21:59:08 GMT</Date>
<Username />
<UserInfo />
<Location>1wIRSNscfkI0qragmfshMiG189qgAf/PumlP3DTbgN4=</Location>
<AAAUN>SFASJNF3U6375H7D1Y4XWJDZ</AAAUN>
<Authorization>WS androidDove:ri6/G20ZNX+bsNyX8GUEB4vSMS4=</Authorization>
<h>test</h>
<Accept-Language>en</Accept-Language>
<Test>false</Test>
<Content-Type>application/json; charset=UTF-8</Content-Type>
<Content-Length>75</Content-Length>
<Host>com.in</Host>
<Accept-Encoding>gzip</Accept-Encoding>
<X-Forwarded-For>0.0.0.0, 0.0.0.0</X-Forwarded-For>
<X-APIRP-ID>0.0.0.0</X-APIRP-ID>
<Via>1.1 69WC0-</Via>
<X-Client-IP>0.0.0.0.</X-Client-IP>
<X-Global-Transaction-ID>RU44D1I3S40ZBVLMQHHUZSB1QOH1HEWO700LZQLB5WR8IGZYU4</X-Global-Transaction-ID>
</Header>
<X />
<URI>/esb/crs2/public/Login</URI>
<ServiceName>PUBLICPOSTOTPLOGIN</ServiceName>
<PrimaryKey />
<Parameters>
<Parameter1 />
<Parameter2 />
<Parameter3 />
<Parameter4 />
</Parameters>
<Body>
<json:object xmlns:json="http://www.ibm.com/" xmlns:xsi="http://www.w3.org/" xsi:schemaLocation="http://www.datapower.com">
<json:string name="phoneNumber">9480562628</json:string>
</json:object>
</Body>
<standardRule>Y</standardRule>
<TRANSACTION_ID>SFASJNF3U6375H7D1Y4XWJDZ</TRANSACTION_ID>
<TRANSACTION_NAME>Login</TRANSACTION_NAME>
<JSON_Body>{ "phoneNumber":"9480562628" }</JSON_Body>
</Input>'
);
Outputs:
PHONENUMBER
9480562628
fiddle
I’m adding some custom properties in the property panel like below,
I diable Id property in the General tab. Adding 2 new tabs Input and Output.
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="Process_1" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:outgoing>Flow_0n4p9tk</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Activity_0d872w2">
<bpmn2:incoming>Flow_0n4p9tk</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_0n4p9tk" sourceRef="StartEvent_1" targetRef="Activity_0d872w2" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNEdge id="Flow_0n4p9tk_di" bpmnElement="Flow_0n4p9tk">
<di:waypoint x="448" y="258" />
<di:waypoint x="500" y="258" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="412" y="240" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0d872w2_di" bpmnElement="Activity_0d872w2">
<dc:Bounds x="500" y="218" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
See 2 screenshots I added new control in the property panel but XML not showing me if I download the diagram. What am I missing in it?
Note: My code is the same replica of the BPMN custom property panel example
I resolved the issue. I able to set input-output parameter in BPMN diagram using the following code,
set: function setValue(element, values, node) {
var b_obj = getBusinessObject(element);
var selectedValues = {};
selectedValues = values;
prop[_id] = selectedValues[_id];
var selectedName = dropdownOptions[parseInt(prop[_id])].name;
var bo = cmdHelper.updateBusinessObject(element, b_obj, prop);
var selectedInputParameter = bpmnFactory.create('camunda:InputParameter', {
name: selectedName,
value: prop[_id]
});
var inputOutput = bpmnFactory.create('camunda:InputOutput', {
inputParameters: [selectedInputParameter]
});
b_obj.extensionElements = b_obj.extensionElements || bpmnFactory.create('bpmn:ExtensionElements');
b_obj.extensionElements.get('values').push(inputOutput);
return bo;
}
I got a hint from here
How to delete the "DrawListAddin" from this list with WIX XmlConfig ?
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance">
<string>ExplorerAddin</string>
<string>DrawListAddin</string>
<string>MyDataAddin</string>
</ArrayOfString>
Result should look like this
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance">
<string>ExplorerAddin</string>
<string>MyDataAddin</string>
</ArrayOfString>
i try multiple settings but nothing work .. the last version looks like this. Searching for the correct item and than remove it. The XML file gets modified but no changes.
<util:XmlConfig Id='XmlSettingsRemove'
On="install"
File='[E3D31_INSTALL_DIR]DesignAddins.xml'
Node='element'
Action='delete'
VerifyPath="//*[\[]text() [\[]contains(.,'DrawListAddin')[\]][\]]"
ElementPath="//ArrayOfString"
Sequence='1'
/>
this code bring an error message that the node could not be found but the "/.." at the end explicit selects the parent correct
<util:XmlConfig Id='XmlSettingsRemove'
On="install"
File='[E3D31_INSTALL_DIR]DesignAddins.xml'
Node='element'
Action='delete'
VerifyPath="/ArrayOfString/string[\[]text()[\[]contains(.,'DrawListAddin')[\]][\]]"
ElementPath="/ArrayOfString/string[\[]text()[\[]contains(.,'DrawListAddin')[\]][\]]/.."
Sequence='1'
/>
just for review .. here is the solution with a embedded script .. i put some placeholder into the code like "DO_SOME_HERE" ..
<CustomAction Id="UnInstallUIFileSetProperty" Property="UnInstallUIFileExec" Value="[PLACE_YOUR_PATH_TO_XML_FILE_HERE]" />
<CustomAction Id="UnInstallUIFileExec" Script="vbscript" Execute='deferred' Impersonate='no' Return='ignore'>
<![CDATA[
on error resume next
c=Session.Property("CustomActionData")
n=c+"ADD_THE_XML_FILENAME_HERE"
Set x = CreateObject("Microsoft.XMLDOM")
x.async = False
x.load(n)
Set r = x.documentElement
Set l = r.getElementsByTagName("string")
For Each e In l
if InStr(e.text,"ENTER_SEARCHTEXT_HERE") then
e.ParentNode.removeChild(e)
end if
Next
if err.Number<>0 then
res=MsgBox("remove of addin failed: "+n)
else
x.Save(n)
end if
]]>
</CustomAction>
I have the following XML contained in a column XML_TRANSACTION in a table TRANSACTION in SQL Server. I am trying to parse out the information inside the From and To tags into separate columns:
<Transaction Id="1234" Timestamp="2012-04-28T05:02:20" Version="TransactionVersion2" SenderId="abcd" SenderLocId="vxyz">
<Instance Name="Home" />
<Messages>
<Message Id="0" Timestamp="2014-04-28T01:00:46">
<MessageRequest Name="Movement" Xsd="Movement.xsd" Version="5">
<Body>
<Parts>
<Part PartNumber="11111" Qty="1" PersonUniqueId="A1B2C3" />
</Parts>
<Order Number="13579" Uid="01" />
<Ship Number="1ZW23" Type="Out" />
<From VendorId="XY1X2" VendorLocId="XY1X2" VendorName="Vendor_Extra" VendorStockRoom="OPEN" CountryCode="US" />
<To VendorId="XY1X2" VendorLocId="XY1X2" VendorName="Vendor_Extra" VendorStockRoom="CLOSED" CountryCode="US" />
</Body>
</MessageRequest>
</Message>
</Messages>
</Transaction>
Desired results:
From_VendorID || From_VendorLocID || From_VendorName || To_VendorID || To_VendorLocID
--------------++------------------++--------------------------------------------------
XY1X2 || XY1X2 || Vendor_Extra || XY1X2 || XY1X2
etc.
I have made several attempts, but have been unsuccessful. Any assistance would be greatly appreciated!
This should get you started:
SELECT
t.[XML_TRANSACTION].value('(//From/#VendorId)[1]','varchar(20)') as From_VendorID
,t.[XML_TRANSACTION].value('(//From/#VendorLocId)[1]','varchar(20)') as From_VendorLocID
,t.[XML_TRANSACTION].value('(//To/#VendorLocId)[1]','varchar(20)') as To_VendorLocID
,t.[XML_TRANSACTION].value('(//To/#VendorLocId)[1]','varchar(20)') as To_VendorLocID
FROM [CD].[TEST] AS t
This is a really common question, but I have not been able to get an answer to work. Here is my configuration file:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="CraneUserInterface.log" />
<appendToFile value="true" />
<maxSizeRollBackups value="90" />
<rollingStyle value="Size" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</root>
But I need to determine the actual logging file name at run time. I found a nice example here, but when I try to loop through the collection returned by the call to GetIterators(), I find that that collection is empty.
I need to change the name "CraneUserInterface.log" to "CraneUserInterface_1.log", or 2, or 3, depending on something the program reads at run time. How can I do that?
Here's my first pass at using the code presented in that sample:
static bool ChangeLogFileName(string AppenderName, string NewFilename)
{
// log4net.Repository.ILoggerRepository RootRep;
// RootRep = log4net.LogManager.GetRepository();
log4net.Repository.ILoggerRepository RootRep = m_logger.Logger.Repository;
foreach (log4net.Appender.IAppender iApp in RootRep.GetAppenders())
{
string appenderName = iApp.Name;
if (iApp.Name.CompareTo(AppenderName) == 0
&& iApp is log4net.Appender.FileAppender)
{
log4net.Appender.FileAppender fApp = (log4net.Appender.FileAppender)iApp;
fApp.File = NewFilename;
fApp.ActivateOptions();
return true; // Appender found and name changed to NewFilename
}
}
return false; // appender not found
}
Thanks very much!
What about to use "%property" to define a dynamic 'tag' to the file name (at runtime) ?
<file type="log4net.Util.PatternString" value="~/App_Data/%property{LogName}" />
Explained here: Best way to dynamically set an appender file path
you can use this function :
in this function first get file location that you set in webconfig and after that you can add any path that you want ! like Date ! our Customer ! or .....
WebConfig:
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\t4\\"/>
<appendToFile value="true"/>
<rollingStyle value="Composite"/>
<datePattern value="_yyyy-MM-dd.lo'g'"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="1MB"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date User:%identity IP:%X{addr} Browser: %X{browser} Url: %X{url} [%thread] %-5level %c:%m%n"/>
</layout>
</appender>
Function:
public static void ChangeFileLocation(string _CustomerName,string _Project)
{
XmlConfigurator.Configure();
log4net.Repository.Hierarchy.Hierarchy h =(log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository();
foreach (IAppender a in h.Root.Appenders)
{
if (a is FileAppender)
{
FileAppender fa = (FileAppender)a;
string sNowDate= DateTime.Now.ToLongDateString();
// Programmatically set this to the desired location here
string FileLocationinWebConfig = fa.File;
string logFileLocation = FileLocationinWebConfig + _Project + "\\" + _CustomerName + "\\" + sNowDate + ".log";
fa.File = logFileLocation;
fa.ActivateOptions();
break;
}
}
}
and result like this : C:\t4\TestProject\Customer1\Saturday, August 31, 2013.log