Generate SiteMapXML File using TemplateBuildingBlock (TBB)

In One of the recent project we had to build the sitemap.xml file of the website, in General by default DXA will provide the same in a json Format or else we can built the same in a similar fashion as a normal page like CT and PT where we can show the same in either in .html/.jsp/.asp

But here client wanted to have separate page in an XML format which contains Url, Date and Priority.

It's simple to create the same but need to have basic concepts how we can do this using TBB

Create a New Page Template where the output format is XML 

Create the TBB and upload the .Net Assembly code that you are going to write for Generating SiteMap as an XML Format

Add that TBB to the PT Source Tab I mean Render the same i.e. built the same using Template builder

Then you just need to create an Empty Page with xml output and just publish the page - the TBB will automatically retrieves all the SG elements and its pages and will display accordingly. You can skip if the page extensions are .asp, .Index etc as per your requirements.

I was able to create Sitemap Successfully in Web8.5 with DXA1.7 Project and i was able to SAVE the Sitemap.xml is Perfect Format in the Database but the challenge I faced was while retrieving from DB and show it on Page, the xml which was generated was not being matched by the DXA1.7 Version since it also automatically generates the xml tags. While retrieving we had faced issue regards to the incorrect formats then after several research and analysis - the Generation of Sitemap using TBB is supported by older version of systems i.e. prior to Tridion 2013 sp1 or etc... But not after Web8 with DXA... So we add to figure it out another solution to create the same that will be explained in Next Blog...

But for the above one – if anyone can add some suggestions on fixing it using web8.5 with DXA using TBB are always welcome...

PFA Source Code available at below Location: CLICK HERE

Anonymous