xmllint

Add an attribute using xmllint

与世无争的帅哥 提交于 2020-01-01 09:49:15
问题 I want to add an attribute to the tag, using xmllint . Can I do this is through xmllint? 回答1: Xmllint in not made to edit XML, so I think the answer is “no, you can't”. To edit XML, you can use XMLStarlet, the syntax to add an attribute into existing XML document is: xmlstarlet ed -L -i xpath -t attr -n name -v value file 来源: https://stackoverflow.com/questions/6404277/add-an-attribute-using-xmllint

xmllint to parse a html file

扶醉桌前 提交于 2019-12-23 16:52:53
问题 I was trying to parse out text between specific tags on a mac in various html files. I was looking for the first <H1> heading in the body. Example: <BODY> <H1>Dublin</H1> Using regular expressions for this I believe is an anti pattern so I used xmllint and xpath instead. xmllint --nowarning --xpath '/HTML/BODY/H1[0]' Problem is some of the HTML files contain badly formed tags. So I get errors on the lines of parser error : Opening and ending tag mismatch: UL line 261 and LI </LI> Problem is I

xmllint DTD validation syntax

爱⌒轻易说出口 提交于 2019-12-18 11:15:09
问题 Trying to validate an XML document; however, xmllint is insisting on reading the options as the file so I'm getting FileNotFound exceptions. Just to confirm, I have the xmllint.exe in the same folder as my XML file. I locate the directory in CMD and enter the command: xmllint --noout --valid file.xml The DTD is located within the xml file. However, xmllint is looking for the file ~/--nout . I have tried putting the file before the options, however, the options are then not applied. I'm

No matching global declaration available for the validation root

核能气质少年 提交于 2019-12-18 11:05:32
问题 Background Validate an XML document using a schema. Problem The simplest form of the problem is shown in two files. XML Document <?xml version="1.0"?> <recipe xmlns:r="http://www.namespace.org/recipe"> <r:description> <r:title>sugar cookies</r:title> </r:description> </recipe> XSD Document <?xml version="1.0" encoding="utf-8"?> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:r="http://www.namespace.org/recipe"> <xsd:complexType name="recipe"> <xsd:choice> <xsd

xpath html get all columns 1 and 2 together and concatenate with column “:”

一世执手 提交于 2019-12-14 03:29:40
问题 i have this following command that gets the data from column 2: Table example: <table> <tr> <td>a</td> <td>b</td> <td>c</td> <td>d</td> <td>e</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr> </table> wget -q -O - http://www.example.com | xmllint --html --xpath "//table[@id=\"tableID\"]//tr//td[position() = 2]//text() - 2>/dev/null That outputs something like: 12345 how can I get all both column 1 and column 2 with ":" symbol that appends on each line? Desired

xpath html combine columns

ぐ巨炮叔叔 提交于 2019-12-13 10:52:46
问题 I'm trying to extract data from socks-proxy.net with the IP and port from the website table. I'm using these commands in linux to get the IP and port. How can I combine theme? wget -q -O - "https://socks-proxy.net" | xmllint --html --xpath "//table[@id=\"proxylisttable\"]//tr//td[1]//text()" - 2>/dev/null Output: 103.254.12.3393.12.55.94192:12:44:11 It combines the IP and it its not good that will get all the IP's from the website table wget -q -O - "https://socks-proxy.net" | xmllint --html

XSD nested element

微笑、不失礼 提交于 2019-12-12 19:56:07
问题 <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="game"> <xsd:complexType> <xsd:all> <xsd:element name="info" type="infoType" minOccurs="0"/> </xsd:all> </xsd:complexType> </xsd:element> <xsd:complexType name="infoType"> <xsd:sequence> <xsd:element name="name" type="xsd:string" minOccurs="0" maxOccurs="1"/> <xsd:element name="players" minOccurs="0" maxOccurs="1"> <xsd:complexType mixed="true"> <xsd:attribute name= "number" type="playernum"/> <!

xml_grep get attribute from element

≯℡__Kan透↙ 提交于 2019-12-12 13:41:58
问题 Is it possible (and if so, how) with xml_grep to get the value of a specific attribute from a specific element? I only seem to be able to output the information between tags. example: <eid> <identity nationalnumber="13021912354" dateofbirth="20130219" gender="male"> <name>Menten</name> <firstname>Kasper</firstname> <middlenames>Marie J</middlenames> <nationality>Belg</nationality> <placeofbirth>Sint-Truiden</placeofbirth> <photo>base64-string</photo> </identity> </eid> output the value (in

get attribute value using xmlstarlet or xmllint

旧时模样 提交于 2019-12-12 12:05:03
问题 I have gone through several of questions since last two days but yet to find a solution. Here is my xml: <?xml version="1.0" encoding="UTF-8"?> <Environment xmlns="http://schemas.dmtf.org/ovf/environment/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oe="http://schemas.dmtf.org/ovf/environment/1" xmlns:ve="http://www.vmware.com/schema/ovfenv" oe:id="" ve:vCenterId=""> <PropertySection> <Property oe:key="vami.hostname" oe:value="jal"/> <Property oe:key="vamitimezone" oe:value=

Why am I getting different results using two different ways of validating my XML?

冷暖自知 提交于 2019-12-12 01:43:09
问题 I'm trying to validate an XML file with an XSD file, which doesn't work and I don't know why. I figured out that we could do it on terminal with that example : xmllint --noout --schema owl2-xml.xsd camera.owl But it produces an error, which I particularly don't understand. regexp error : failed to compile: expecting a branch after | owl2-xml.xsd:30: element pattern: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}pattern': The value '([A-Z]|[a-z]|[À-Ö]|[Ø-ö]|[ø-˿]|[Ͱ-ͽ]|[Ϳ-῿