gpt4 book ai didi

xml - 如何在没有源 xml 文件根节点的情况下将一个 xml 文件包含在另一个 xml 中?

转载 作者:行者123 更新时间:2023-12-05 05:23:58 32 4
gpt4 key购买 nike

正如标题中所问,我有两个如下结构的 XML 文件

A.xml

<Root>
<J>
<N>
//here I want to include B.xml
</N>
</J>
</Root>

B.xml

<Root>
<M></M>
<O></O>
<P></P>
</Root>

我可以使用 Xinclude,但这也在 A.xml 中包含了 B.XML 的 Root 元素。在包含如下所示的 B.xml 之后,我想要 A.xml

<Root>
<J>
<N>
<M></M>
<O></O>
<P></P>
</N>
</J>
</Root>

请帮我解决这个问题。

最佳答案

看这里:

https://blogs.gnome.org/shaunm/2011/07/21/understanding-xinclude/

你可以这样做:

<include href="someFile.xml" xpointer="xpointer(/Root/M)"  xmlns="http://www.w3.org/2001/XInclude"/>
<include href="someFile.xml" xpointer="xpointer(/Root/O)" xmlns="http://www.w3.org/2001/XInclude"/>
<include href="someFile.xml" xpointer="xpointer(/Root/P)" xmlns="http://www.w3.org/2001/XInclude"/>

可能是更好的方法 - 只是介绍一个想法。

或者,如果您可以选择尝试不同的 xml 结构。例如,B.xml 可以将“N”作为其根音吗?

<N>
<M>
<O>
<P>
</N>

然后包含上一级文件。当然,这很可能是不可能的,N 可能有其他内容,或者您​​可能无法更改 xml 结构。

关于xml - 如何在没有源 xml 文件根节点的情况下将一个 xml 文件包含在另一个 xml 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36396906/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com