我正在为类别制作一个 XML 映射文件。我想知道正确的方法是考虑我想到的两个选项。
我的主要问题是可能必须读取 XML 文件的 php 代码的速度/效率。所以这是我的第一种方法
<?xml version="1.0" encoding="utf-8"?>
<category-map lang="en_US" reader="Candor Framework">
<for-her url="/content/syl/tags/for-her">
<women-tops url="/content/syl/category/15/women-tops">
<women-longsleeve-tops url="/content/syl/tags/women-longsleeve-tops">Longsleeve Tops</women-longsleeve-tops>
<women-shortsleeve-tops url="/content/syl/tags/women-shortsleeve-tops">Shortsleeve Tops</women-shortsleeve-tops>
</women-tops>
<women-gowns url="/content/syl/category/18/women-gowns/">
<short-gowns url="/content/syl/tags/short-gowns">Short Gowns</short-gowns>
<evening-gowns url="/content/syl/tags/evening-gowns">Evening Gowns</evening-gowns>
</women-gowns>
<women-shoes url="/content/syl/category/19/women-shoes/">
<women-highheel-shoes url="/content/syl/tags/women-highheel-shoes">High Heel Shoes</women-highheel-shoes>
<women-wedge-shoes url="/content/syl/tags/women-wedge-shoes">Wedge Shoes</women-wedge-shoes>
</women-shoes>
</for-her>
<for-him url="/content/syl/tags/for-him">
<men-shirt url="/content/syl/category/20/men-shirt">
<men-lonsleeve-shirt url="/content/syl/tags/men-longsleeve-shirt">Longsleeve Shirt</women-longsleeve-tops>
</men-shirt>
</for-him>
</category-map>
使用这种方法,所有 XML 标记都有唯一的名称。现在与第二种方法进行比较。
<?xml version="1.0" encoding="utf-8"?>
<category-map lang="en_US" reader="Candor Framework">
<target name="for-her" url="/content/syl/tags/for-her">
<category name="women-tops" url="/content/syl/category/15/women-tops">
<tag name="women-longsleeve-tops" url="/content/syl/tags/women-longsleeve-tops">Longsleeve Tops</tag>
<tag name="women-shortsleeve-tops" url="/content/syl/tags/women-shortsleeve-tops">Shortsleeve Tops</tag>
</category>
<category name="women-gowns" url="/content/syl/category/18/women-gowns/">
<tag name="short-gowns" url="/content/syl/tags/short-gowns">Short Gowns</tag>
<tag name="evening-gowns" url="/content/syl/tags/evening-gowns">Evening Gowns</tag>
</category>
<category name="women-shoes" url="/content/syl/category/19/women-shoes/">
<tag name="women-highheel-shoes" url="/content/syl/tags/women-highheel-shoes">High Heel Shoes</tag>
<tag name="women-wedge-shoes" url="/content/syl/tags/women-wedge-shoes">Wedge Shoes</tag>
</category>
</target>
<target name="for-him" url="/content/syl/tags/for-him">
<category name="men-shirt" url="/content/syl/category/20/men-shirt">
<tag name="men-lonsleeve-shirt" url="/content/syl/tags/men-longsleeve-shirt">Longsleeve Shirt</tag>
</category>
</target>
</category-map>
这是 XML 文件的简短版本。整个内容还蛮多的。这些设计方法中哪一种更快?哪一种需要更少的循环和条件?建议遵循哪一个,为什么?
非常感激!