xmlstarlet

Extract values from XML using xmlstarlet

拜拜、爱过 提交于 2019-12-10 12:07:39
问题 How can I extract using xmlstarlet the local port from this xml example: <?xml version="1.0"?> <opmn xmlns="http://www.oracle.com/ias-instance"> <notification-server> <port local="6101" remote="6200" request="6003"/> <log-file path="$ORACLE_HOME\opmn\logs\ons.log" level="4" rotation-size="1500000"/> <ssl enabled="true" wallet-file="$ORACLE_HOME\opmn\conf\ssl.wlt\default"/> </notification-server> </opmn> 回答1: xml sel -N ias=http://www.oracle.com/ias-instance -t -v //ias:port/@local example.xml

xmlstarlet select value based on condition

不羁的心 提交于 2019-12-10 10:17:33
问题 Based on this link, I am trying to solve a similar problem. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <groupId>com.foo</groupId> <artifactId>iwidget</artifactId> <packaging>jar</packaging> <version>0.9.1b</version> <name>iwidget</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency>

xmlstarlet: filter out element with attribute

随声附和 提交于 2019-12-08 01:59:47
问题 How to filter out elements of certain type which to not have an attribute with a magic value and retain the rest of the document? All this using xmlstarlet ? What I have to far is: cat << EOF > database.xml <?xml version="1.0"?> <database> <some name="A" /> <some name="B" /> <some name="C" /> <text>this is some text to be applied...</text> <project> <test deeper="structure"/> </project> </database> EOF and xmlstarlet sel -t -m "*" -c "*[not(self::some[@name != 'A'])]" database.xml yields

Why does xmlstarlet say there's no 'ends-with' function?

微笑、不失礼 提交于 2019-12-08 00:59:37
问题 I'm using xmlstarlet to extract changeSet nodes from a liquibase XML changelog where the viewName ends with "v". However, xmlstarlet is complaining that the ends-with XPATH function does not exist: $ xmlstarlet sel -N x="http://www.liquibase.org/xml/ns/dbchangelog" -t -m \ "/x:databaseChangeLog/x:changeSet[x:createView[ends-with(@viewName, 'v')]]" \ -c . public.db.changelog.xml xmlXPathCompOpEval: function ends-with not found Unregistered function Stack usage errror xmlXPathCompiledEval: 3

How to use XML namespaces with xmlstarlet XPaths?

99封情书 提交于 2019-12-07 09:31:47
问题 at the moment I am struggeling editing a XML file. When I write the command xml ed -u "/project/version" -v "2.7.13-NEW-SNAPSHOT" pom.xml > ./pom_new.xml it writes the new xml file, but when I open the file nothings changed in it. Heres a part of the given xml, i want to edit: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache

XMLStarlet and RSS

可紊 提交于 2019-12-07 02:19:27
I can't seem to get this basic xslt query working via xmlstarlet. I'm sure I'm missing something obvious, but for the life of me I cannot figure out this syntax, so someone please illuminate me. XML Starlet Command: xml sel -t -m "//rdf:RDF/item" -v link -v description -v link ./sss.rdf sss.rdf: <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl

Conditionals in XML file using xmlstarlet

雨燕双飞 提交于 2019-12-06 14:42:47
Considering the codes in here and here , I've changed them to explain my question. Now the code looks like this: <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <Description> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <stock>YES</stock> </Description> <Location> <restock>UMG</restock> <shelf>30</shelf> </Location> </book> <book category="CHILDREN"> <Description> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <stock>NO</stock> </Description> <Location> <restock>GIP<

xmlstarlet: filter out element with attribute

有些话、适合烂在心里 提交于 2019-12-06 12:01:08
How to filter out elements of certain type which to not have an attribute with a magic value and retain the rest of the document? All this using xmlstarlet ? What I have to far is: cat << EOF > database.xml <?xml version="1.0"?> <database> <some name="A" /> <some name="B" /> <some name="C" /> <text>this is some text to be applied...</text> <project> <test deeper="structure"/> </project> </database> EOF and xmlstarlet sel -t -m "*" -c "*[not(self::some[@name != 'A'])]" database.xml yields <some name="A"/><text>this is some text to be applied...</text><project> <test deeper="structure"/> <

xmlstarlet replace xml node value

≯℡__Kan透↙ 提交于 2019-12-06 10:37:22
问题 I'm new using xmlstarlet. I'd like to know how to change the value of xml node using xmlstarlet. I tried something. xmlstarlet ed --inplace -u '/file_input/uri' 'string("s3://my_source")' template.xml > output.xml doesn't work. My expected output as s3://my_source and s3://mydestination . I'd like to change source_path and destination_path node. <?xml version="1.0" encoding="UTF-8"?> <job version="2.10.8"> <input> <deblock_enable>Auto</deblock_enable> <deblock_strength>0</deblock_strength>

xmlstarlet- Update a value on a specific node

余生颓废 提交于 2019-12-06 10:35:30
问题 I want to update a value in the xml file through command line. I'm new to xmlstartlet I tried with the following command but its not working xml ed -u "/web-app/welcome-file-list/welcome-file" -v 'Login.jsp' web.xml In the followig XML file I want to update the value as login.jsp on the welcome-file node. This is my web.xml file <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi