ben34
April 7, 2022, 8:25am
#1
HI All
I am trying to use powershell to remove the euro currency symbol from a XML file but no matter what I replace it with it goes from this: “returning dr pearl rrp€375”
To this:
returning dr pearl rrp-'375
Can anyone suggest the best way to just remove the currency symbol without leaving any other symbol in its place?
Thanks
Ben
Hi, welcome back
Please can you post some sample XML code so we can see what it looks like in the XML, and also the code you’re using to do the replacement.
When posting the code, please use the </> button to format your code. This will ensure we can see everything, including any control characters.
ben34
April 7, 2022, 9:41am
#3
HI Matt
one variation of the code I tried to use:
<$xml = [xml](Get-Content -Path D:\ECM_IPMS\Polling\001000I\OUT\invoice.xml)
$node = $xml.selectSingleNode('//DOCUMENT/INVOICES/INVOICE/INVC_ITEMS')
$node.item_note1 = ""
$xml.Save("D:\ECM_IPMS\Polling\001000I\OUT\invoice.xml")>
see below XML example:
"<?xml version="1.0" encoding="UTF-8"?>
<!-- Created on 2022-03-29T23:00:19+01:00 -->
<!-- V9 STATION -->
<DOCUMENT>
<INVOICES>
<INVOICE invc_sid="7734861128985488461" sbs_no="3" store_no="10" invc_no="8271" invc_type="0" hisec_type="" status="0" proc_status="0" cust_sid="" addr_no="1" shipto_cust_sid="5991692514391166972" shipto_addr_no="1" station="" workstation="1" orig_store_no="10" orig_station="" use_vat="1" vat_options="0" so_no="" so_sid="" cust_po_no="" note="" disc_perc="0" disc_amt="0" disc_perc_spread="" over_tax_perc="" over_tax_perc2="" tax_reb_perc="" tax_reb_amt="" rounding_offset="" created_date="2022-03-29T10:45:13" modified_date="2022-03-29T10:45:13+01:00" post_date="2022-03-29T10:45:13" tracking_no="" ref_invc_sid="" audited="0" cms_post_date="2022-03-29T10:55:30" ws_seq_no="10894" cust_fld="" held="0" drawer_no="1" controller="3010" orig_controller="3010" elapsed_time="329" till_name="" activity_perc="100" activity_perc2="" activity_perc3="" activity_perc4="" activity_perc5="" eft_invc_no="10132" detax="0" doc_ref_no="" fiscal_doc_id="" subloc_code="" subloc_id="" ship_perc="" trans_disc_amt="" empl_sbs_no="3" empl_name="CATMUL" tax_area_name="IRE" tax_area2_name="" ref_invc_no="" ref_invc_created_date="" createdby_sbs_no="3" createdby_empl_name="" modifiedby_sbs_no="3" modifiedby_empl_name="" clerk_sbs_no="3" clerk_name="" clerk_sbs_no2="" clerk_name2="" clerk_sbs_no3="" clerk_name3="" clerk_sbs_no4="" clerk_name4="" clerk_sbs_no5="" clerk_name5="" disbur_reason_type="" disbur_reason_name="" doc_reason_code="">
<CUSTOMER cust_sid="" cust_id="" store_no="10" station="" first_name="" last_name="" price_lvl="" detax="0" info1="" info2="" modified_date="2022-03-29T10:55:31+01:00" sbs_no="3" cms="1" company_name="" title="MS" tax_area_name="" shipping="" address1="" address2="" address3="" address4="" address5="" address6="" zip="" phone1="" phone2="" country_name="" alternate_id1="" alternate_id2=""/>
<SHIPTO_CUSTOMER cust_sid="" cust_id="" store_no="10" station="" first_name="" last_name="" price_lvl="" detax="0" info1="" info2="" modified_date="2022-03-29T10:55:31+01:00" sbs_no="3" cms="1" company_name="" title="MS" tax_area_name="" shipping="" address1="" address2="" address3="" address4="" address5="" address6="" zip="" phone1="" phone2="" country_name="" alternate_id1="" alternate_id2=""/>
<INVC_SUPPLS>
</INVC_SUPPLS>
<INVC_COMMENTS>
</INVC_COMMENTS>
<INVC_EXTRAS>
</INVC_EXTRAS>
<INVC_FEES>
</INVC_FEES>
<INVC_TENDERS>
<INVC_TENDER tender_type="0" tender_no="1" taken="0" given="0" amt="0" doc_no="" auth="" reference="" chk_company="" chk_first_name="" chk_last_name="" chk_work_phone="" chk_home_phone="" chk_state_code="" chk_dl="" chk_dl_exp_date="" chk_dob_date="" crd_exp_month="" crd_exp_year="" crd_normal_sale="1" crd_contr_no="" crd_present="0" crd_zip="" crd_proc_fee="" gft_crd_trace_no="" gft_crd_int_ref_no="" gft_crd_balance="" charge_net_days="" charge_disc_days="" charge_disc_perc="" pmt_date="" pmt_remark="" matched="0" manual_name="" manual_remark="" transaction_id="" avs_code="0" chk_type="0" cashback_amt="" l2_result_code="" signature_map="" orig_crd_name="" tender_state="0" failure_msg="" proc_date="" orig_currency_name="EURO" eftdata0="" eftdata1="" eftdata2="" eftdata3="" eftdata4="" eftdata5="" eftdata6="" eftdata7="" eftdata8="" eftdata9="" eftdata10="" eftdata11="" eftdata12="" eftdata13="" eftdata14="" eftdata15="" eftdata16="" eftdata17="" eftdata18="" eftdata19="" eftdatabsmer="" eftdatabscust="" cardholder_name="" give_rate="" take_rate="" base_taken="" base_given="" cent_txn_id="" balance_remaining="" cent_commit_txn="0" emv_aid="" emv_applabel="" emv_card_exp_date="" emv_cyrpto_type="" emv_cryptogram="" emv_pin_statement="" cayan_sf_id="" cayan_trans_key="" cayan_locale="" crd_name="" currency_name="EURO"/>
</INVC_TENDERS>
<INVC_COUPONS>
</INVC_COUPONS>
<INVC_ITEMS>
<INVC_ITEM item_pos="1" item_sid="2153740" qty="-1" orig_price="250" orig_tax_amt="46.74797" price="0" tax_code="0" tax_perc="23" tax_amt="0" tax_code2="" tax_perc2="" tax_amt2="" cost="0" price_lvl="1" spif="" sched_no="" comm_code="" comm_amt="0" cust_fld="" scan_upc="" serial_no="" lot_number="" kit_flag="0" pkg_item_sid="" pkg_seq_no="" orig_cmpnt_item_sid="" detax="0" usr_disc_perc="0" udf_value1="" udf_value2="" udf_value3="" udf_value4="" activity_perc="100" activity_perc2="" activity_perc3="" activity_perc4="" activity_perc5="" comm_amt2="0" comm_amt3="0" comm_amt4="0" comm_amt5="0" so_sid="" so_orig_item_pos="" item_origin="" pkg_no="" shipto_cust_sid="" shipto_addr_no="" orig_cost="" item_note1="returning dr pearl rrp€375" item_note2="" item_note3="" item_note4="" item_note5="" item_note6="" item_note7="" item_note8="" item_note9="" item_note10="" promo_flag="0" gift_activation_code="" gift_transaction_id="" returned_qty="" ref_item_pos="" ref_invc_sid="" gift_add_value="0" ref_invc_no="" alt_upc="" alt_alu="" alt_cost="" alt_vend_code="" orig_prc_bdt="" prc_bdt="" gift_eftdata0="" gift_eftdata1="" gift_eftdata2="" gift_eftdata3="" gift_eftdata4="" gift_eftdata5="" gift_eftdata6="" gift_eftdata7="" gift_eftdata8="" gift_eftdata9="" gift_eftdata10="" gift_eftdata11="" gift_eftdata12="" gift_eftdata13="" gift_eftdata14="" gift_eftdata15="" gift_eftdata16="" gift_eftdata17="" gift_eftdata18="" gift_eftdata19="" gift_eftdatabsmer="" gift_eftdatabscust="" subloc_code="" subloc_id="" tender_state="0" failure_msg="" proc_date="" cent_commit_txn="0" price_flag="0" force_orig_tax="" sn_qty="" sn_active="" sn_received="" sn_sold="" sn_transferred="" sn_so_reserved="" sn_returned="" sn_returned_to_vnd="" sn_adjusted="" tax_perc_lock="0" ref_store_no="" tax_area2_name="" empl_sbs_no="3" empl_name="CATMUL" disc_reason_name="UNFRM" empl_sbs_no2="" empl_name2="" empl_sbs_no3="" empl_name3="" empl_sbs_no4="" empl_name4="" empl_sbs_no5="" empl_name5="" ship_method="" item_reason_type="0" item_reason_name="ChgMnd" lot_expiry_date="">
<INVN_BASE_ITEM item_sid="2153740" upc="5054760724091" alu="2153740" style_sid="2175116422415" dcs_code="001200217" vend_code="51164" scale_no="" description1="DR PEARL" description2="PEARL" description3="BLU-MULTI" description4="" attr="BLU-MULT" siz="CLT 16" use_qty_decimals="0" tax_code="0" flag="" ext_flag="" item_no="" udf3_value="" udf4_value="" udf5_value="" udf6_value="" aux1_value="" aux2_value="" aux3_value="PC040100 - GENERAL" aux4_value="COTTON MIX" aux5_value="SS21" aux6_value="" aux7_value="" aux8_value=""/>
</INVC_ITEM>
<INVC_ITEM item_pos="2" item_sid="2158194" qty="1" orig_price="265" orig_tax_amt="49.55285" price="0" tax_code="0" tax_perc="23" tax_amt="0" tax_code2="" tax_perc2="" tax_amt2="" cost="0" price_lvl="1" spif="0" sched_no="" comm_code="" comm_amt="0" cust_fld="" scan_upc="" serial_no="" lot_number="" kit_flag="0" pkg_item_sid="" pkg_seq_no="" orig_cmpnt_item_sid="" detax="0" usr_disc_perc="0" udf_value1="" udf_value2="" udf_value3="" udf_value4="" activity_perc="100" activity_perc2="" activity_perc3="" activity_perc4="" activity_perc5="" comm_amt2="0" comm_amt3="0" comm_amt4="0" comm_amt5="0" so_sid="" so_orig_item_pos="" item_origin="" pkg_no="" shipto_cust_sid="" shipto_addr_no="" orig_cost="" item_note1="CT MAISIE RRP €400 " item_note2="" item_note3="" item_note4="" item_note5="" item_note6="" item_note7="" item_note8="" item_note9="" item_note10="" promo_flag="0" gift_activation_code="" gift_transaction_id="" returned_qty="" ref_item_pos="" ref_invc_sid="" gift_add_value="0" ref_invc_no="" alt_upc="" alt_alu="" alt_cost="" alt_vend_code="" orig_prc_bdt="" prc_bdt="" gift_eftdata0="" gift_eftdata1="" gift_eftdata2="" gift_eftdata3="" gift_eftdata4="" gift_eftdata5="" gift_eftdata6="" gift_eftdata7="" gift_eftdata8="" gift_eftdata9="" gift_eftdata10="" gift_eftdata11="" gift_eftdata12="" gift_eftdata13="" gift_eftdata14="" gift_eftdata15="" gift_eftdata16="" gift_eftdata17="" gift_eftdata18="" gift_eftdata19="" gift_eftdatabsmer="" gift_eftdatabscust="" subloc_code="" subloc_id="" tender_state="0" failure_msg="" proc_date="" cent_commit_txn="0" price_flag="0" force_orig_tax="" sn_qty="" sn_active="" sn_received="" sn_sold="" sn_transferred="" sn_so_reserved="" sn_returned="" sn_returned_to_vnd="" sn_adjusted="" tax_perc_lock="0" ref_store_no="" tax_area2_name="" empl_sbs_no="3" empl_name="CATMUL" disc_reason_name="UNFRM" empl_sbs_no2="" empl_name2="" empl_sbs_no3="" empl_name3="" empl_sbs_no4="" empl_name4="" empl_sbs_no5="" empl_name5="" ship_method="" item_reason_type="" item_reason_name="" lot_expiry_date="">
<INVN_BASE_ITEM item_sid="2158194" upc="5054760728549" alu="2158194" style_sid="220511567688" dcs_code="001200220" vend_code="51156" scale_no="" description1="CT MAISIE TIE CUFF MOB" description2="MAISIE" description3="PIN-PALE ROSE" description4="" attr="PIN-PALE" siz="CLT 16" use_qty_decimals="0" tax_code="0" flag="" ext_flag="" item_no="" udf3_value="" udf4_value="" udf5_value="" udf6_value="" aux1_value="UNKNOWN" aux2_value="" aux3_value="UNKNOWN" aux4_value="POLYESTER MIX" aux5_value="SS21" aux6_value="" aux7_value="" aux8_value=""/>
</INVC_ITEM>
</INVC_ITEMS>
</INVOICE>
</INVOICES>
</DOCUMENT>"
Certain field data have been blanked out for security reasons
Olaf
April 7, 2022, 9:43am
#4
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
How to format code in PowerShell.org
1 Like
ben34
April 7, 2022, 9:54am
#5
Hi Olaf
I tried that but it didnt work
<<?xml version="1.0" encoding="UTF-8"?>
/>
Olaf
April 7, 2022, 10:17am
#6
Try harder! Click the link and watch the GIF to see how it works!!
And you don’t have to create a new post every time - you can should edit your existing ones!!!
ben34
April 7, 2022, 10:30am
#7
The gif figured it out, I didnt release it was a button the forum
Olaf
April 7, 2022, 10:34am
#8
ben34:
The gif figured it out
… so you are more the visual learner …
1 Like
Olaf
April 7, 2022, 11:45am
#9
I’m not sure … try this …
$xml = [xml](Get-Content -Path D:\ECM_IPMS\Polling\001000I\OUT\invoice.xml)
$xml.selectNodes('//DOCUMENT/INVOICES/INVOICE/INVC_ITEMS/INVC_ITEM') |
ForEach-Object {
$WithoutEuroSign = ($_ | Select-Object "item_note1")."item_note1" -replace '€'
$_.SetAttribute("item_note1", $WithoutEuroSign)
}
$xml.Save("D:\ECM_IPMS\Polling\001000I\OUT\invoice_mod.xml")
2 Likes
ben34
April 19, 2022, 10:38am
#10
Hi Olaf
Thank you for that, unfortunately the end user has found a different way in their software of removing the symbol.
I do appreciate all efforts.
Thanks
Ben
Olaf
April 19, 2022, 10:56am
#11
Why is that “unfortunate ”. This way it is less work and less responsibility for you.