Parsing xmllint-使用名称空间解析xml文件

Parsing xmllint-使用名称空间解析xml文件,parsing,namespaces,xmllint,Parsing,Namespaces,Xmllint,我在stackoverflow上找到了很多关于xmllint及其“名称空间支持”的主题,但没有一个对我有帮助 以下是我的xml(确切地说是xsd)文件: 但它不起作用。我得到“分割错误” 更新 我还有一个问题: 我应该使用什么来获取此文件中标记的属性“toto”值: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t

我在stackoverflow上找到了很多关于xmllint及其“名称空间支持”的主题,但没有一个对我有帮助

以下是我的xml(确切地说是xsd)文件:

但它不起作用。我得到“分割错误”

更新

我还有一个问题: 我应该使用什么来获取此文件中标记的属性“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>

我的文本

换句话说,我想获取“TestAttributeValue”

您的XML,它是无效的,因为没有声明“xsd”前缀(甚至在问题的第二个.version中编辑的命令输出中也报告了这一点)

您想要的是
xmlns:xsd=
而不是
xmlns=


另外,
name()
返回一个QName。您想使用
local-name()
来匹配本地名称。

我知道这是很久以前的事了,但是您还记得如何获得toto属性的值吗?
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()"
<?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>