Package: pandasxmledit
simplifies working with XML data by leveraging the power and flexibility of pandas DataFramesTested against Windows 10 / Python 3.11 / Anacondapip install pandasxmleditEffortlessly Manipulate XML Data with Pandas DataFramespandasxmledit is a Python library that simplifies the process of working with XML data by providing an intuitive interface through pandas DataFrames.
It allows you to easily load, edit, and save XML data, all within the familiar pandas ecosystem.
Whether you're a data scientist, data analyst, or software developer, PandasXMLEdit streamlines XML data processing and empowers you to work more efficiently.Key FeaturesSeamless Integration:Leverage the power of pandas to manipulate and analyze XML data effortlessly. Integrate XML data processing seamlessly into your data workflows.Automatic Data Type Conversion:Optionally, automatically convert XML values to their appropriate data types, simplifying data transformation tasks.Data Filtering and Modification:Filter, update, and manipulate XML data with ease using DataFrame operations. Apply calculations and transformations to specific elements.XML Data Serialization:Update the original XML data with changes made to the DataFrame and save the updated XML to a file.Error Handling:Built-in error handling ensures robust XML data processing from various sources, including URLs and local files.# Create a PandasXMLEdit instance with XML data from a URLfrompandasxmleditimportPandasXMLEditxmledit=PandasXMLEdit(xmldata="https://github.com/hansalemaos/screenshots/raw/main/xmlexample.xml",convert_dtypes=True,process_namespaces=False,)# Modify values in the DataFramexmledit.df.loc[xmledit.df.key_3=='author','value']='Stephen King'xmledit.df.loc[xmledit.df.key_3=='price','value']*=10# Update the XML data with DataFrame changesxmledit.update_xml_data(pretty=True)# Display the updated XML data and its dictionary representationprint(xmledit.xmldata)print(xmledit.xmldict)# Save the updated XML data to a filexmledit.save_xml(r"c:\updatedxml.xml")Original XML<?xml version="1.0"?><catalog><bookid="bk101"><author>Gambardella,Matthew</author><title>XMLDeveloper'sGuide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>Anin-depthlookatcreatingapplicationswithXML.</description></book><bookid="bk102"><author>Ralls,Kim</author><title>MidnightRain</title><genre>Fantasy</genre><price>5.95</price><publish_date>2000-12-16</publish_date><description>Aformerarchitectbattlescorporatezombies,anevilsorceress,andherownchildhoodtobecomequeenoftheworld.</description></book><bookid="bk103"><author>Corets,Eva</author><title>MaeveAscendant</title><genre>Fantasy</genre><price>5.95</price><publish_date>2000-11-17</publish_date><description>AfterthecollapseofananotechnologysocietyinEngland,theyoungsurvivorslaythefoundationforanewsociety.</description></book><bookid="bk104"><author>Corets,Eva</author><title>Oberon'sLegacy</title><genre>Fantasy</genre><price>5.95</price><publish_date>2001-03-10</publish_date><description>Inpost-apocalypseEngland,themysteriousagentknownonlyasOberonhelpstocreateanewlifefortheinhabitantsofLondon.SequeltoMaeveAscendant.</description></book><bookid="bk105"><author>Corets,Eva</author><title>TheSunderedGrail</title><genre>Fantasy</genre><price>5.95</price><publish_date>2001-09-10</publish_date><description>ThetwodaughtersofMaeve,half-sisters,battleoneanotherforcontrolofEngland.SequeltoOberon'sLegacy.</description></book><bookid="bk106"><author>Randall,Cynthia</author><title>LoverBirds</title><genre>Romance</genre><price>4.95</price><publish_date>2000-09-02</publish_date><description>WhenCarlameetsPaulatanornithologyconference,tempersflyasfeathersgetruffled.</description></book><bookid="bk107"><author>Thurman,Paula</author><title>SplishSplash</title><genre>Romance</genre><price>4.95</price><publish_date>2000-11-02</publish_date><description>Adeepseadiverfindstruelovetwentythousandleaguesbeneaththesea.</description></book><bookid="bk108"><author>Knorr,Stefan</author><title>CreepyCrawlies</title><genre>Horror</genre><price>4.95</price><publish_date>2000-12-06</publish_date><description>Ananthologyofhorrorstoriesaboutroaches,centipedes,scorpionsandotherinsects.</description></book><bookid="bk109"><author>Kress,Peter</author><title>ParadoxLost</title><genre>ScienceFiction</genre><price>6.95</price><publish_date>2000-11-02</publish_date><description>AfteraninadvertanttripthroughaHeisenbergUncertaintyDevice,JamesSalwaydiscoverstheproblemsofbeingquantum.</description></book><bookid="bk110"><author>O'Brien,Tim</author><title>Microsoft.NET:TheProgrammingBible</title><genre>Computer</genre><price>36.95</price><publish_date>2000-12-09</publish_date><description>Microsoft's.NETinitiativeisexploredindetailinthisdeepprogrammer'sreference.</description></book><bookid="bk111"><author>O'Brien,Tim</author><title>MSXML3:AComprehensiveGuide</title><genre>Computer</genre><price>36.95</price><publish_date>2000-12-01</publish_date><description>TheMicrosoftMSXML3parseriscoveredindetail,withattentiontoXMLDOMinterfaces,XSLTprocessing,SAXandmore.</description></book><bookid="bk112"><author>Galos,Mike</author><title>VisualStudio7:AComprehensiveGuide</title><genre>Computer</genre><price>49.95</price><publish_date>2001-04-16</publish_date><description>MicrosoftVisualStudio7isexploredindepth,lookingathowVisualBasic,VisualC++,C#,andASP+areintegratedintoacomprehensivedevelopmentenvironment.</description></book></catalog>updated XML<?xml version="1.0" encoding="utf-8"?><catalog><bookid="bk101"><author>StephenKing</author><title>XMLDeveloper'sGuide</title><genre>Computer</genre><price>449.5</price><publish_date>2000-10-01</publish_date><description>Anin-depthlookatcreatingapplicationswithXML.</description></book><bookid="bk102"><author>StephenKing</author><title>MidnightRain</title><genre>Fantasy</genre><price>59.5</price><publish_date>2000-12-16</publish_date><description>Aformerarchitectbattlescorporatezombies,anevilsorceress,andherownchildhoodtobecomequeenoftheworld.</description></book><bookid="bk103"><author>StephenKing</author><title>MaeveAscendant</title><genre>Fantasy</genre><price>59.5</price><publish_date>2000-11-17</publish_date><description>AfterthecollapseofananotechnologysocietyinEngland,theyoungsurvivorslaythefoundationforanewsociety.</description></book><bookid="bk104"><author>StephenKing</author><title>Oberon'sLegacy</title><genre>Fantasy</genre><price>59.5</price><publish_date>2001-03-10</publish_date><description>Inpost-apocalypseEngland,themysteriousagentknownonlyasOberonhelpstocreateanewlifefortheinhabitantsofLondon.SequeltoMaeveAscendant.</description></book><bookid="bk105"><author>StephenKing</author><title>TheSunderedGrail</title><genre>Fantasy</genre><price>59.5</price><publish_date>2001-09-10</publish_date><description>ThetwodaughtersofMaeve,half-sisters,battleoneanotherforcontrolofEngland.SequeltoOberon'sLegacy.</description></book><bookid="bk106"><author>StephenKing</author><title>LoverBirds</title><genre>Romance</genre><price>49.5</price><publish_date>2000-09-02</publish_date><description>WhenCarlameetsPaulatanornithologyconference,tempersflyasfeathersgetruffled.</description></book><bookid="bk107"><author>StephenKing</author><title>SplishSplash</title><genre>Romance</genre><price>49.5</price><publish_date>2000-11-02</publish_date><description>Adeepseadiverfindstruelovetwentythousandleaguesbeneaththesea.</description></book><bookid="bk108"><author>StephenKing</author><title>CreepyCrawlies</title><genre>Horror</genre><price>49.5</price><publish_date>2000-12-06</publish_date><description>Ananthologyofhorrorstoriesaboutroaches,centipedes,scorpionsandotherinsects.</description></book><bookid="bk109"><author>StephenKing</author><title>ParadoxLost</title><genre>ScienceFiction</genre><price>69.5</price><publish_date>2000-11-02</publish_date><description>AfteraninadvertanttripthroughaHeisenbergUncertaintyDevice,JamesSalwaydiscoverstheproblemsofbeingquantum.</description></book><bookid="bk110"><author>StephenKing</author><title>Microsoft.NET:TheProgrammingBible</title><genre>Computer</genre><price>369.5</price><publish_date>2000-12-09</publish_date><description>Microsoft's.NETinitiativeisexploredindetailinthisdeepprogrammer'sreference.</description></book><bookid="bk111"><author>StephenKing</author><title>MSXML3:AComprehensiveGuide</title><genre>Computer</genre><price>369.5</price><publish_date>2000-12-01</publish_date><description>TheMicrosoftMSXML3parseriscoveredindetail,withattentiontoXMLDOMinterfaces,XSLTprocessing,SAXandmore.</description></book><bookid="bk112"><author>StephenKing</author><title>VisualStudio7:AComprehensiveGuide</title><genre>Computer</genre><price>499.5</price><publish_date>2001-04-16</publish_date><description>MicrosoftVisualStudio7isexploredindepth,lookingathowVisualBasic,VisualC++,C#,andASP+areintegratedintoacomprehensivedevelopmentenvironment.</description></book></catalog>