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>
Related
I'm trying to get tag "" from xml below.
If i execute request like this:
WITH x(col) AS (select'<document xmlns="http://example.com/digital/back/" xmlns:ns2="http://example.com/digital/back/complexId" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="">
<header>
<docId>13a2f29a28b12ecb</docId>
<dt>2018-12-10T11:59:48.112+03:00</dt>
</header>
<pay>
<reqTransfer id="154638">
<source>
<card>
<virtualCardNum>4B74C1EE187</virtualCardNum>
<bsc>VISA</bsc>
</card>
</source>
</reqTransfer>
</pay>
</document>
'::xml)
SELECT xpath('/document/pay/reqTransfer/source/card/bsc/text()', col) AS bsc
FROM x;
I get {}, but if I relpace the document start tag
<document xmlns="http://example.com/digital/back/" xmlns:ns2="http://example.com/digital/back/complexId" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="">
with <document> or even <document xmlns="">, I get { VISA } - that is right.
What should I do to replace <document xmlns="..."> with <document> or get { VISA } without replacement?
If you are working with XML namespaces, they are worth mentioning in your Xpath queries too, i.e. use
SELECT xpath('/d:document/d:pay/d:reqTransfer/d:source/d:card/d:bsc/text()', col,
ARRAY[ARRAY['d', 'http://example.com/digital/back/']]) AS bsc
http://sqlfiddle.com/#!17/9eecb/24719
See also:
how to ignore namespaces with XPath
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")
I want to highlight syntax for my programming language of choice (proprietary) in Microsoft OneNote 2013 with a macro or script. I found a free Macro creator for MS OneNote '13 that allows creation of custom macros called "OneTastic". I created a macro that is given two arrays with lists of predefined words associated with different colors to give each list (ex: List 1 words = blue, list 2 words = orange, etc.)
API: https://www.omeratay.com/onetastic/docs/
Problem: The search logic is finding words inside of bigger words, like "IN" inside of the word "domain" (domaIN). My code is below:
<?xml version="1.0" encoding="utf-16"?>
<Macro name="CCL TEST 3" category="Color" description="" version="10">
<ModifyVar name="KEYWORDS1" op="set">
<Function name="String_Split">
<Param name="string" value="drop create program go %i declare call set end END execute else elseif protect constant curqual of subroutine to noconstant record free range in is protect define macro endmacro" />
<Param name="delimiter" value=" " />
</Function>
</ModifyVar>
<ModifyVar name="counter" op="set" value="0" />
<WhileVar name="counter" op="lt">
<Function name="Array_Length">
<Param name="array" var="KEYWORDS1" />
</Function>
<IsRootOp />
<ModifyVar name="keyword" op="set" var="KEYWORDS1">
<RightIndex var="counter" />
</ModifyVar>
<For each="Text">
<That hasProp="value" op="eq" var="keyword" />
<ModifyProp name="fontColor" op="set" value="blue" />
</For>
<ModifyVar name="counter" op="add" value="1" />
</WhileVar>
<ModifyVar name="KEYWORDS2" op="set">
<Function name="String_Split">
<Param name="string" value="datetimefind datetimediff cnvtdatetime cnvtalias format build concat findfile error alterlist alter initrec cnvtdate esmError echo max min avg sum count uar_get_code_meaning mod substring size trim hour day isnumeric expand locateval cnvtstring fillstring btestfindstring logical uar_get_code_display uar_get_meaning_by_codeset UAR_GET_CODE_BY sqltype cnvtreal echorecord cnvtupper cnvtlower cnvtdatetimeutc abs datetimediff year julian btest decode evaluate findstring asis replace validate nullterm parser value uar_timer_create uar_CreatePropList uar_SetPropString uar_CloseHandle uar_Timer_Destroy uar_Timer_Stop build2 patstring piece cnvtalphanum timestampdiff" />
<Param name="delimiter" value=" " />
</Function>
</ModifyVar>
<ModifyVar name="counter2" op="set" value="0" />
<WhileVar name="counter2" op="lt">
<Function name="Array_Length">
<Param name="array" var="KEYWORDS2" />
</Function>
<IsRootOp />
<ModifyVar name="keyword" op="set" var="KEYWORDS2">
<RightIndex var="counter2" />
</ModifyVar>
<For each="Text">
<That hasProp="value" op="eq" var="keyword" />
<ModifyProp name="fontColor" op="set" value="orange" />
</For>
<ModifyVar name="counter2" op="add" value="1" />
</WhileVar>
</Macro>
There is no such inbuilt feature available in OneNote but you can do it.
Use Visual Studio Code, it's free. Turn on right text copy/pasting. Write your code in in VS code. Copy it. It'll paste exactly as you see. Colors and all.
While this does not use VBA, I use and love the add-in NoteHightlight2016
If you don't find a language you can go through and add your own. I've added the Excel Formula keywords to the languages supported and I believe it is a bit easier than creating in OneTastic, which I also use and love.
I am not able to retrieve unique list by applying Muenchian method. I am trying to group based on "Series Title" attribute
Sample Input XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Distribution>
<ManifestHeader>
<Assets>
<Asset>
<ID>23341528</ID>
<CreateDate>2008-01-14T17:02:01Z</CreateDate>
<MetaDatas>
<MetaData Name="psa.orig.source.showTitle">Green Home 2008</MetaData>
<MetaData Name="displayRunTime">00:01</MetaData>
<MetaData Name="Series Title">Desperate Landscapes</MetaData>
</MetaDatas>
</Asset>
<Asset>
<ID>23341529</ID>
<CreateDate>2010-08-23T15:44:58Z</CreateDate>
<MetaDatas>
<MetaData Name="psa.orig.source.showTitle">Urban Oasis 2010</MetaData>
<MetaData Name="displayRunTime">00:02</MetaData>
<MetaData Name="Series Title">Toy Hunter</MetaData>
</MetaDatas>
</Asset>
<Asset>
<ID>23377202</ID>
<CreateDate>2007-05-18T07:40:25Z</CreateDate>
<MetaDatas>
<MetaData Name="webSeries"/>
<MetaData Name="psa.orig.source.showTitle">Cool Tools</MetaData>
<MetaData Name="displayRunTime">00:20</MetaData>
<MetaData Name="Series Title">Desperate Landscapes</MetaData>
</MetaDatas>
</Asset>
</Assets>
</ManifestHeader>
</Distribution>
XLST:
<xsl:key name="keySeriesName" match="MetaData[#Name='Series Title']" use="text()" />
<xsl:for-each select="MetaData[#Name='Series Title'][generate-id() =
generate-id(key('keySeriesName', text())[1])]">
also tried:
<xsl:for-each select="MetaData[#Name='Series Title'][count(. | key('keySeriesName',text())[1]) = 1]">
anyhelp would be appreciated
Thanks in advance
Since the <MetaData> elements are children of <MetaData> and you are trying to search across the entire collection of them within the document, you are going to need to adjust your XPath to ensure that you are addressing all of them:
/Distribution/ManifestHeader/Assets/Asset/MetaDatas/MetaData
[#Name='Series Title'][generate-id() =
generate-id(key('keySeriesName', text())[1])]
or you could use the shorter, but less efficient:
//MetaData[#Name='Series Title'][generate-id() =
generate-id(key('keySeriesName', text())[1])]
I am trying to using lxml's ElementTree etree to find a specific tag in my xml document.
The tag looks as follows:
<text:ageInformation>
<text:statedAge>12</text:statedAge>
</text:ageInformation>
I was hoping to use etree.find('text:statedAge'), but that method does not like 'text' prefix.
It mentions that I should add 'text' to the prefix map, but I am not certain how to do it. Any tips?
Edit:
I want to be able to write to the hr4e prefixed tags.
Here are the important parts of the document:
<?xml version="1.0" encoding="utf-8"?>
<greenCCD xmlns="AlschulerAssociates::GreenCDA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hr4e="hr4e::patientdata" xsi:schemaLocation="AlschulerAssociates::GreenCDA green_ccd.xsd">
<header>
<documentID root="18c41e51-5f4d-4d15-993e-2a932fed720a" />
<title>Health Records for Everyone Continuity of Care Document</title>
<version>
<number>1</number>
</version>
<confidentiality codeSystem="2.16.840.1.113883.5.25" code="N" />
<documentTimestamp value="201105300211+0800" />
<personalInformation>
<patientInformation>
<personID root="2.16.840.1.113883.3.881.PI13023911" />
<personAddress>
<streetAddressLine nullFlavor="NI" />
<city>Santa Cruz</city>
<state nullFlavor="NI" />
<postalCode nullFlavor="NI" />
</personAddress>
<personPhone nullFlavor="NI" />
<personInformation>
<personName>
<given>Benjamin</given>
<family>Keidan</family>
</personName>
<gender codeSystem="2.16.840.1.113883.5.1" code="M" />
<personDateOfBirth value="NI" />
<hr4e:ageInformation>
<hr4e:statedAge>9424</hr4e:statedAge>
<hr4e:estimatedAge>0912</hr4e:estimatedAge>
<hr4e:yearInSchool>1</hr4e:yearInSchool>
<hr4e:statusInSchool>attending</hr4e:statusInSchool>
</hr4e:ageInformation>
</personInformation>
<hr4e:livingSituation>
<hr4e:homeVillage>Putney</hr4e:homeVillage>
<hr4e:tribe>Oromo</hr4e:tribe>
</hr4e:livingSituation>
</patientInformation>
</personalInformation>
The namespace prefix must be declared (mapped to an URI) in the XML document. Then you can use the {URI}localname notation to find text:statedAge and other elements. Something like this:
from lxml import etree
XML = """
<root xmlns:text="http://example.com">
<text:ageInformation>
<text:statedAge>12</text:statedAge>
</text:ageInformation>
</root>"""
root = etree.fromstring(XML)
ageinfo = root.find("{http://example.com}ageInformation")
age = ageinfo.find("{http://example.com}statedAge")
print age.text
This will print "12".
Another way of doing it:
ageinfo = root.find("text:ageInformation",
namespaces={"text": "http://example.com"})
age = ageinfo.find("text:statedAge",
namespaces={"text": "http://example.com"})
print age.text
You can also use XPath:
age = root.xpath("//text:statedAge",
namespaces={"text": "http://example.com"})[0]
print age.text
I ended up having to use nested prefixes:
from lxml import etree
XML = """
<greenCCD xmlns="AlschulerAssociates::GreenCDA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hr4e="hr4e::patientdata" xsi:schemaLocation="AlschulerAssociates::GreenCDA green_ccd.xsd">
<personInformation>
<hr4e:ageInformation>
<hr4e:statedAge>12</hr4e:statedAge>
</hr4e:ageInformation>
</personInformation>
</greenCCD>"""
root = etree.fromstring(XML)
#root = etree.parse("hr4e_patient.xml")
ageinfo = root.find("{AlschulerAssociates::GreenCDA}personInformation/{hr4e::patientdata}ageInformation")
age = ageinfo.find("{hr4e::patientdata}statedAge")
print age.text