xmlstarlet

xmlstarlet XPath expression selects single result rather than multiple

廉价感情. 提交于 2019-12-02 03:14:17
问题 I have an XML file having structure like this: <?xml version="1.0" encoding="UTF-8"?> <hudson> <authorizationStrategy> <roleMap type="globalRoles"> <role name="Employees"> <assignedSIDs> <sid>abc</sid> <sid>bcd</sid> </assignedSIDs> </role> </roleMap> <roleMap type="projectRoles"> <role name="test1" pattern=".*"> <assignedSIDs> <sid>abc</sid> <sid>zxc</sid> </assignedSIDs> </role> <role name="test2" pattern=".*"> <permissions/> <assignedSIDs> <sid>abc</sid> <sid>ghi</sid> </assignedSIDs> <

xmlstarlet XPath expression selects single result rather than multiple

纵然是瞬间 提交于 2019-12-02 02:39:28
I have an XML file having structure like this: <?xml version="1.0" encoding="UTF-8"?> <hudson> <authorizationStrategy> <roleMap type="globalRoles"> <role name="Employees"> <assignedSIDs> <sid>abc</sid> <sid>bcd</sid> </assignedSIDs> </role> </roleMap> <roleMap type="projectRoles"> <role name="test1" pattern=".*"> <assignedSIDs> <sid>abc</sid> <sid>zxc</sid> </assignedSIDs> </role> <role name="test2" pattern=".*"> <permissions/> <assignedSIDs> <sid>abc</sid> <sid>ghi</sid> </assignedSIDs> </role> <role name="test3" pattern=".*"> <permissions/> <assignedSIDs> <sid>abc</sid> </assignedSIDs> <

Using xmlstarlet, how do I change the value of an element

。_饼干妹妹 提交于 2019-12-01 22:21:02
问题 Using xmlstarlet how can replace the value for all instances of ThreadGroup.num_threads please? Before <stringProp name="ThreadGroup.num_threads">FOOO BARR</stringProp> After <stringProp name="ThreadGroup.num_threads">99999</stringProp> Here's the XML snippet <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Blogs" enabled="true"> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> <elementProp name="ThreadGroup.main_controller" elementType=

Using xmlstarlet, how do I change the value of an element

雨燕双飞 提交于 2019-12-01 21:27:32
Using xmlstarlet how can replace the value for all instances of ThreadGroup.num_threads please? Before <stringProp name="ThreadGroup.num_threads">FOOO BARR</stringProp> After <stringProp name="ThreadGroup.num_threads">99999</stringProp> Here's the XML snippet <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Blogs" enabled="true"> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" enabled="true"> <boolProp name=

xmlstarlet update value nothing happens

爱⌒轻易说出口 提交于 2019-12-01 20:13:05
I have an xml file <?xml version="1.0"?> <preferences> <!--General options--> <options> <dbHost>localhost</dbHost> <dbUser>bwserver</dbUser> <dbPass>bwserver</dbPass> <dbPort>3306</dbPort> How can i update the value dbUser? When I type xmlstarlet edit --update '/preferences/options/dbUser/' --value 123 preferences.xml nothing happens. I only see the file contents in terminal. The xml file was not touched. You have two faults: Your XPath expression is invalid. Drop the trailing slash so it becomes /preferences/options/dbUser By default xmlstarlet does not change the input file, instead it

xmlstarlet update value nothing happens

孤街浪徒 提交于 2019-12-01 18:58:33
问题 I have an xml file <?xml version="1.0"?> <preferences> <!--General options--> <options> <dbHost>localhost</dbHost> <dbUser>bwserver</dbUser> <dbPass>bwserver</dbPass> <dbPort>3306</dbPort> How can i update the value dbUser? When I type xmlstarlet edit --update '/preferences/options/dbUser/' --value 123 preferences.xml nothing happens. I only see the file contents in terminal. The xml file was not touched. 回答1: You have two faults: Your XPath expression is invalid. Drop the trailing slash so

How to declare XPath namespaces in xmlstarlet?

╄→гoц情女王★ 提交于 2019-12-01 15:49:45
I am new to xmlstarlet so hoping this answer is a simple one. I am writing a script to modify Inkscape SVG files from the command line. I chose the tool xmlstarlet. After testing the command syntax on test files, I am having trouble on the real SVG files. I think the use of namespaces is throwing me off. Example file: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www

How to declare XPath namespaces in xmlstarlet?

微笑、不失礼 提交于 2019-12-01 15:20:47
问题 I am new to xmlstarlet so hoping this answer is a simple one. I am writing a script to modify Inkscape SVG files from the command line. I chose the tool xmlstarlet. After testing the command syntax on test files, I am having trouble on the real SVG files. I think the use of namespaces is throwing me off. Example file: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"

How do I insert an element directly after another element with XMLStarlet?

我只是一个虾纸丫 提交于 2019-12-01 03:51:33
问题 With this example XML: <rootnode> <element-a /> <element-b /> <element-d /> <element-e /> </rootnode> How do I insert element <element-c/> directly after the element <element-b/> using XMLStarlet? 回答1: xml ed -i (or --insert) will put the it before the node, xml ed -a (or --append) will put it after, so you can use either one of: xml ed -i /rootnode/element-d -t elem -n element-c -v "" file.xml xml ed -a /rootnode/element-b -t elem -n element-c -v "" file.xml 来源: https://stackoverflow.com

Why does this XPath expression not return the correct value in xmlstarlet?

♀尐吖头ヾ 提交于 2019-12-01 01:12:29
I'm trying to extract the contents of the 'coordinates' node in this KML file using xmlstarlet. The KML file validates fine using xmlstarlet itself. I've whittled it down to a small test file containing: <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2"> <Document> <Placemark> <name>eurovelo-5 690</name> <Snippet></Snippet> <description><![CDATA[ ]]></description> <styleUrl>#style390</styleUrl> <LineString> <tessellate>1</tessellate> <coordinates> 10.146948,44.790592,97.500000 10.146958,44.790562,97.599998 10.147018,44.790497,97.699997 10.147083,44.790466,97