vb.net - 获取 XSD 架构元素的 Xpath
可以在 vb.net 中检索 XSD 模式 text() 元素的 Xpath 吗?例如,如何从以下模式中获取此 Xpath;
父母/孩子/孙子
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="parent">
<xs:complexType>
<xs:sequence>
<xs:element name="child">
<xs:complexType>
<xs:sequence>
<xs:element name="grandchild"
type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Can the Xpath of XSD schema text() elements be retrieved in vb.net? For example, how can you get this Xpath from the following schema;
parent/child/grandchild
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="parent">
<xs:complexType>
<xs:sequence>
<xs:element name="child">
<xs:complexType>
<xs:sequence>
<xs:element name="grandchild"
type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的基本目标是确定(在代码中)任意两个节点之间的 xpath。例如,如果父节点有一个 child2 节点,我可以获取孙子的 child2 节点作为祖先::parent/child2
我的想法是,如果我有两个节点的完整 xpath,我可以确定相对路径(祖先,后代) 节点之间。我会将每个文本节点的完整 xpath 存储在数据库中(如果有更好的方法,我们将不胜感激)。
我的问题是“我可以从 xsd 架构生成完整路径吗?”
Alejandro,我想使用 //text() 从实例文档中执行此操作,并且可行。
LarsH,我相信孙节点和 child2 节点之间只有一条路径。
感谢您的回复。
My essential goal is to determine (in code) the xpath between any two nodes. For example, if the parent had a child2 node, I could obtain the child2 node of grandchild as ancestor::parent/child2
My thought was that if I have the full xpath to both nodes, I could determine the relative path (ancestor, descendant) between the nodes. I would store the full xpath of every text node in the database (a better approach would be appreciated).
My question was 'can i generate the full paths from the xsd schema?'
Alejandro, I thought of doing this from an instance document using //text() and that works.
LarsH, I believe there would only be one path between the grandchild node and the child2 node.
Thanks for your responses.