使用XML文件从HTML中读取嵌套的Groupbox [英] Making nested Groupboxes in HTML reading from XML file

查看:89
本文介绍了使用XML文件从HTML中读取嵌套的Groupbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XML和C#winform生成HTML代码。我的XML看起来像这样:



I am generating an HTML code using XML and C# winform. My XML looks like this:

<Groups>
<Group Name="Group1" ID="D7EBC5D6-0E6D-499E-B528-34BE14382755">
</Group>
<Group Name="Group2" ID="CC012258-14AC-44E9-BA0F-78AE7C569FCB" parent="D7EBC5D6-0E6D-499E-B528-34BE14382755">
</Group>
<Group Name="Group3" ID="E23D7E3B-9DDA-408E-9CC9-9AC1A9E36DD3" parent="D7EBC5D6-0E6D-499E-B528-34BE14382755">
</Group>





第4行和第6行中''parent''元素的ID表示这些标签是此ID的子项(在本例中为组1的ID)



我尝试了几种不同的方法,但它们没有用。不得更改XML。如何在HTML中生成多个嵌套组框?



The Id of ''parent'' element in lines 4 and 6 shows that these tags are the children of this ID(in this case the ID of group 1)

I have tried several different ways but they did not work. The XML must not be changed. How can I generate several nested group boxes in HTML?

推荐答案

我不确定您究竟要开发什么。假设您希望根据xml上描述的布局创建嵌套的HTML字段集(通常用于元素分组)。



您可以从您在此处获取的xml构建一个中间xml文档对象(临时)。这很容易。使用一些递归函数遍历给定布局xml的所有元素并生成修改后的xml,如下所示。



I am not sure what exactly you are trying to develop. As assumption is that you want to create nested HTML field set (which is normally used for grouping of elements) based on the lay out described on your xml.

You may construct an intermediate xml document object (temporarily) from the xml that you gaven here. It is pretty easy. Use some recursive function to traverse through all elements of the given layout xml and generate the modified xml as follows.

<Groups>
    <Group Name="Group1" ID="D7EBC5D6-0E6D-499E-B528-34BE14382755">
        <Group Name="Group2" ID="CC012258-14AC-44E9-BA0F-78AE7C569FCB"/>
        <Group Name="Group3" ID="E23D7E3B-9DDA-408E-9CC9-9AC1A9E36DD3"/>
    </Group>
</Groups>





完成后,您可以轻松构建嵌套字段集HTML 。





Once this is done, you could construct the nested fieldset HTML easily.

<fieldset>
    <legend>Group1</legend>
    <fieldset>
        <legend>Group2</legend>
    </fieldset>
    <fieldset>
        <legend>Group3</legend>
    </fieldset>
</fieldset>





如果需要,您可以进行其他定制。中级xml构造不是强制性的。您可以直接从布局xml构造字段集HTML。但是如果你必须多次创建,那么你可以缓存中间的xml。



干杯,



You may do some other customization if you want. Intermediate xml construction is not mandatory. You may directly construct the fieldset HTML from your lay out xml. But if you have to create this many times, then you may cache the intermediate xml.

Cheers,


这篇关于使用XML文件从HTML中读取嵌套的Groupbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆