Hello,
I was wondering if someone could help me combine elements within an xml file, giving priority to a specific element depending on the attribute. For instance, the initial file looks like this:
===
<content>
<pages>
<page idl="/index_en" label="Home" position="1" tags=""/>
<page idl="/news_en" label="News" position="2" tags=""""/>
<page idl="/news/sample_en" label="Sample Story" position="3" tags=""news""/>
<page idl="/test_en" label="Test Page" position="4" tags=""/>
</pages>
<files>
<file idl="/index_en" tags="home"/>
<file idl="/news_en" tags="news"/>
<file idl="/news/sample_en" tags=""news""/>
<file idl="/test_en" tags=""/>
</files>
</content>
===
And I'm trying to get an output similar to:
===
<pages>
<page idl="/index_en" label="Home" position="1" tags="home"/>
<page idl="/news_en" label="News" position="2" tags=""news""/>
<page idl="/news/sample_en" label="Sample Story" position="3" tags=""news""/>
<page idl="/test_en" label="Test Page" position="4" tags=""/>
</pages>
===
So, I need it to search and find the matching file and page attributes (that have the same idl), then combine them into a new page element. Having said that, I want the "label" attribute to come from the original page element and the tag attribute to come from the original file element.
If anyone has some advise it would be appreciated.
I was wondering if someone could help me combine elements within an xml file, giving priority to a specific element depending on the attribute. For instance, the initial file looks like this:
===
<content>
<pages>
<page idl="/index_en" label="Home" position="1" tags=""/>
<page idl="/news_en" label="News" position="2" tags=""""/>
<page idl="/news/sample_en" label="Sample Story" position="3" tags=""news""/>
<page idl="/test_en" label="Test Page" position="4" tags=""/>
</pages>
<files>
<file idl="/index_en" tags="home"/>
<file idl="/news_en" tags="news"/>
<file idl="/news/sample_en" tags=""news""/>
<file idl="/test_en" tags=""/>
</files>
</content>
===
And I'm trying to get an output similar to:
===
<pages>
<page idl="/index_en" label="Home" position="1" tags="home"/>
<page idl="/news_en" label="News" position="2" tags=""news""/>
<page idl="/news/sample_en" label="Sample Story" position="3" tags=""news""/>
<page idl="/test_en" label="Test Page" position="4" tags=""/>
</pages>
===
So, I need it to search and find the matching file and page attributes (that have the same idl), then combine them into a new page element. Having said that, I want the "label" attribute to come from the original page element and the tag attribute to come from the original file element.
If anyone has some advise it would be appreciated.