xmllint とその「名前空間のサポート」について、stackoverflow で多くのトピックを見つけましたが、どれも役に立ちませんでした。
これが私のxml(正確にはxsd)ファイルです:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation>My Text</xsd:documentation>
</xsd:annotation>
</xsd:schema>
このファイルから「My Text」チェーンを取得したいので、これを試します:
xmllint myfile.xsd --xpath "/*[namespace-uri()='http://www.w3.org/2001/XMLSchema' and
name()='schema']/*[namespace-uri()='http://www.w3.org/2001/XMLSchema' and
name()='annotation']/*[namespace-uri()='http://www.w3.org/2001/XMLSchema' and
name()='documentation']/text()"
しかし、うまくいきません。「セグメンテーション違反」が発生します。
アップデート
別の質問があります: このファイルでタグの属性「toto」値を取得するには、何を使用すればよいですか?
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:toto="testAtributeValue">
<xsd:annotation>
<xsd:documentation>myText</xsd:documentation>
</xsd:annotation>
</xsd:schema>
言い換えれば、「testAtributeValue」を取得したい