vb.net - 获取 XSD 架构元素的 Xpath

发布于 2024-09-24 08:26:29 字数 899 浏览 0 评论 0原文

可以在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏雪无痕 2024-10-01 08:26:29

我的基本目标是确定(在代码中)任意两个节点之间的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文