xmlstarlet

No finding tag with XMLStarlet that contains >

这一生的挚爱 提交于 2019-12-25 04:11:47
问题 I'm working with XMLStarlet in a bash script to basically find specific XML nodes based on what has changed on git within that file. This is working fine until we hit a node that needs to be searched that contains > as part of it's value. Example of the node that I want to find: <?xml version="1.0" encoding="UTF-8"?> <CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata"> <labels> <fullName>Button_Value_Get_Data</fullName> <categories>Button Value</categories> <language>en_US</language

Can XmlStarlet preserve CDATA during copy?

。_饼干妹妹 提交于 2019-12-24 14:37:27
问题 How can I make XmlStarlet preserve CDATA when using copy? The <![CDATA[ ]]> must be maintained because the application that generated (and uses) the data insists on having the CDATA directive around certain data. Example.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RSLogix5000Content SchemaRevision="1.0" SoftwareRevision="20.01" > <Controller Use="Target" Name="SOME_TARGET_NAME" ProcessorType="1789-L60"> <Tags> <Tag Name="gstrScrap" TagType="Base" DataType="STRING" Constant=

how to ignore attribute without quotes in xml

青春壹個敷衍的年華 提交于 2019-12-24 14:23:44
问题 i want to count how many times tag1 occurs givin this 123.xml file ( streaming from the internet) <startend> <tag1 name=myname> <date>10-10-10</date> </tag1 > <tag1 name=yourname> <date>11-10-10</date> </tag1 > </startend> using : xmlstarlet sel -t -v "count(//tag1)" 123.xml output : AttValue: " or ' expected attributes construct error how to ignore that the attribute has no " " ? 回答1: You input XML/HTML structure has invalid tags/attributes and should be recovered beforehand: xmlstarlet

xmlstarlet Search Attribute

陌路散爱 提交于 2019-12-24 10:41:11
问题 XML Example: <?xml version="1.0" encoding="UTF-8"?> <profile> <section name="Vision"> <key name="Name" value="BBBB"/> <key name="Name_Remark" value="GGGG"/> <key name="Position" value="30"/> </section> </profile> How I can get value with xmlstarlet where name is "Position". Now is 30. Thank you. 回答1: You can use this command line... xmlstarlet sel -t -v "/profile/section/key[@name='Position']/@value" -n input.xml The sel command tells xmlstarlet to select. The -t option tells xmlstarlet the

Concatenate a value to an existing xml attribute using XMLStarlet (Image Annotation)

倾然丶 夕夏残阳落幕 提交于 2019-12-24 07:37:51
问题 I am working on annotating images using xml. I am using xmlstarlet and unix bash commands but I am facing some issues when I try to append a value to an existing xml attribute value. For example, I have <filename>a</filename> and I want to make it <filename>a.jpg</filename> (i.e. concatenate '.jpg' to the existing value). I used the following piece of code but it totally overwrites the value (i.e. <filename>.jpg</filename> . Script: for name in *.xml; do xmlstarlet ed --inplace -u '

xmlstarlet - removing linefeed

允我心安 提交于 2019-12-23 09:04:22
问题 I have the following file log.xml : <entry> <message>Line 1 Line 2 and so on</message> </entry> On CentOS 5.4 using xmlstarlet 1.0.1 if I run the following command, while removing linefeed in message : xml sel -t -m //entry -v "translate(message,' ' ,'@')" log.xml The result is: Line 1@ Line 2 and so on On CentOS 6 using xmlstarlet: 1.3.1 compiled against libxml2 2.7.6, linked with 20706 compiled against libxslt 1.1.26, linked with 10126 I'll receive: Line 1 Line 2 nd so on Note "and"

Conditionals in XML file using xmlstarlet

不羁岁月 提交于 2019-12-23 02:22:34
问题 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

How to search for a XML node and add or delete it using xmlstarlet

戏子无情 提交于 2019-12-23 02:20:17
问题 I try to create a shell script that searches in an XML file for an attribute and create an element with the given attribute if this doesn't exist or delete the element if the attribute exists. Here is the XML File: <configuration name="distributor.conf" description="Distributor Configuration"> <lists> <list name="CRproductionLoadshare"> <node name="fs100" weight="2"/> <node name="fs101" weight="2"/> </list> <list name="AnyOtherGroup"> <node name="fs100" weight="2"/> </list> </lists> <

How to search for a XML node and add or delete it using xmlstarlet

喜夏-厌秋 提交于 2019-12-23 02:20:04
问题 I try to create a shell script that searches in an XML file for an attribute and create an element with the given attribute if this doesn't exist or delete the element if the attribute exists. Here is the XML File: <configuration name="distributor.conf" description="Distributor Configuration"> <lists> <list name="CRproductionLoadshare"> <node name="fs100" weight="2"/> <node name="fs101" weight="2"/> </list> <list name="AnyOtherGroup"> <node name="fs100" weight="2"/> </list> </lists> <

XMLStarlet does not select anything

北城余情 提交于 2019-12-20 11:45:13
问题 I have a typical pom.xml, and want to print the groupId, artifactId and version, separated by colon. I think that XMLStarlet is the right tool for that. I tried several ways, but I always get an empty line. xml sel -t -m project -v groupId -o : -v artifactId -o : -v version pom.xml Expected output: org.something.apps:app-acct:5.4 Real output: empty line Even if I try to print just the groupId I get nothing: xml sel -t -v project/groupId pom.xml I am sure that the tool sees the elements