Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:39:18+00:00 2026-06-07T07:39:18+00:00

I have an XML feed that I have transformed into HTML for a dynamic

  • 0

I have an XML feed that I have transformed into HTML for a dynamic Drupal page, courtesy of the nice users at drupal.stackexchange.com. The issue, however, is that the XML feed lists everything that could possibly ever need to be known, and my requirements are that each page renders a certain subset of information.

Essentially, it is a presentation schedule that needs to be broken down.

My example feed is as follows:

<track name="Track 1">
  <session name="Session 1" starttime="2012-06-06 10:45" endtime="2012-06-06 12:45">
    <presentation name="Presentation 1">
       <author>Name 1</author>
       <author>Name 2</author>
       <abstract>summary of this presentation</abstract>
    </presentation>
    <presentation name="Presentation 2">
      ...presentation info
    </presentation>
  </session>

  <session name="Session 2" starttime="2012-06-06 10:45" endtime="2012-06-06 12:45">
    <presentation name="Presentation 3">
      ...presentation info
    </presentation>
    <presentation name="Presentation 4">
      ...presentation info
    </presentation>
  </session>

  <session name="Session 3" starttime="2012-06-07 08:45" endtime="2012-06-07 10:45">
    <presentation name="Presentation 5">
      ...presentation info
    </presentation>
    <presentation name="Presentation 6">
      ...presentation info
    </presentation>
  </session>
</track>

So, as you can see, I get all information for this entire proceeding. Every single track, session, and presentation all in one feed. As of right now, I can parse that into a dynamic page without any issue.

Essentially, here is what I would like to get it to (ignoring the parsing of the dateTime…I have that in place already):

<h2>Track 1</h2>
<h3>Session 1</h3>
<ul>
  <li><a href="presentation-1.html">Presentation 1</a></li>
  <li><a href="presentation-2.html">Presentation 2</a></li>
</ul>
<h3>Sessoin 2</h3>
<ul>
  <li><a href="presentation-3.html">Presentation 3</a></li>
  <li><a href="presentation-4.html">Presentation 4</a></li>
</ul>

And then, clicking one of the presentation links would take you to a new page:

<h2>Presentation 1</h2>
<p>Presented by Name 1, Name 2</p>
<p>summary of this presentation</p>

So, I have two issues here … I don’t exactly know how to break up a feed in this manner, and this must be done within a Drupal 6 module. I am just showing a snippet of a sample feed…because the feed that I do get is quite large, and must be broken up in this manner.

The Drupal code that I have is as follows:

function _xml_import_generate()
{
  $path = drupal_get_path('module', 'xml_import');
  $xsl = new DOMDocument();
  $xsl->load("{$path}/xml_import.xsl");

  $xslt = new XSLTProcessor(); 
  $xslt->importStyleSheet($xsl);

  $xml = new DOMDocument();
  $xml->load("myfeed.xml");

  return (string) $xslt->transformToXML($xml);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:39:19+00:00Added an answer on June 7, 2026 at 7:39 am

    I. For the first page you want:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="/">
         <html>
           <xsl:apply-templates/>
         </html>
     </xsl:template>
    
     <xsl:template match="track">
       <h2><xsl:value-of select="@name"/></h2>
       <xsl:apply-templates>
        <xsl:with-param name="pTrack" select=
             "count(preceding-sibling::track) +1"/>
       </xsl:apply-templates>
     </xsl:template>
    
     <xsl:template match="session">
      <xsl:param name="pTrack"/>
       <h3><xsl:value-of select="@name"/></h3>
       <ul>
         <xsl:apply-templates>
            <xsl:with-param name="pTrack" select="$pTrack"/>
            <xsl:with-param name="pSess" select=
                "count(preceding-sibling::session) +1"/>
         </xsl:apply-templates>
       </ul>
     </xsl:template>
    
     <xsl:template match="presentation">
      <xsl:param name="pTrack"/>
      <xsl:param name="pSess" />
      <li>
        <a href=
        "presentation.html?track={$pTrack}&amp;sess={$pSess}&amp;pr={position()}">
          <xsl:value-of select="@name"/>
        </a>
      </li>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <conference>
        <track name="Track 1">
          <session name="Session 1" starttime="2012-06-06 10:45" endtime="2012-06-06 12:45">
            <presentation name="Presentation 1">
               <author>Name 1</author>
               <author>Name 2</author>
               <abstract>summary of this presentation</abstract>
            </presentation>
            <presentation name="Presentation 2">
              ...presentation info
            </presentation>
          </session>
    
          <session name="Session 2" starttime="2012-06-06 10:45" endtime="2012-06-06 12:45">
            <presentation name="Presentation 3">
              ...presentation info
            </presentation>
            <presentation name="Presentation 4">
              ...presentation info
            </presentation>
          </session>
    
          <session name="Session 3" starttime="2012-06-07 08:45" endtime="2012-06-07 10:45">
            <presentation name="Presentation 5">
              ...presentation info
            </presentation>
            <presentation name="Presentation 6">
              ...presentation info
            </presentation>
          </session>
        </track>
    </conference>
    

    this useful result is produced:

    <html>
       <h2>Track 1</h2>
       <h3>Session 1</h3>
       <ul>
          <li><a href="presentation.html?track=1&amp;sess=1&amp;pr=1">Presentation 1</a></li>
          <li><a href="presentation.html?track=1&amp;sess=1&amp;pr=2">Presentation 2</a></li>
       </ul>
       <h3>Session 2</h3>
       <ul>
          <li><a href="presentation.html?track=1&amp;sess=2&amp;pr=1">Presentation 3</a></li>
          <li><a href="presentation.html?track=1&amp;sess=2&amp;pr=2">Presentation 4</a></li>
       </ul>
       <h3>Session 3</h3>
       <ul>
          <li><a href="presentation.html?track=1&amp;sess=3&amp;pr=1">Presentation 5</a></li>
          <li><a href="presentation.html?track=1&amp;sess=3&amp;pr=2">Presentation 6</a></li>
       </ul>
    </html>
    

    II. The second page:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:param name="track" select="1"/>
     <xsl:param name="sess" select="1"/>
     <xsl:param name="pr" select="1"/>
    
     <xsl:template match="/*">
         <html>
           <xsl:apply-templates select=
             "track[position()=$track]
                      /session[position()=$sess]
                          /presentation[position()=$pr]"/>
         </html>
     </xsl:template>
    
     <xsl:template match="presentation">
      <h2><xsl:value-of select="@name"/></h2>
      <p>Presented by <xsl:text/>
        <xsl:apply-templates select="author"/>
      </p>
      <p><xsl:copy-of select="abstract/node()"/></p>
     </xsl:template>
    
     <xsl:template match="author">
      <xsl:if test="position() > 1">, </xsl:if>
      <xsl:value-of select="."/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document (above), the wanted, correct result is produced:

    <html>
       <h2>Presentation 1</h2>
       <p>Presented by Name 1, Name 2</p>
       <p>summary of this presentation</p>
    </html>
    

    Do note:

    Whenever the end-user clicks on a link on the first page, the web server must process this web-request and must invoke the second transformation, passing to it the external/global parameters, whose values it must properly set from the corresponding query-string parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML feed that im pulling via javascript and translating it into
I have a XML feed of products that I break down into smaller XML
I have an XML feed that I've retrieved via httpwebrequest, and I'm having problems
I have an xml feed that I have to check periodically for updates. The
I have a client that sends an xml feed which I parse using the
I have a class which parse an XML feed. In that class I have
I have an XML feed that looks something like this: I can parse the
I have built a site that relies on an XML feed that I currently
I have a xml feed with some html in one of my nodes. So
I have a tableView that loads an XML feed as follows: - (void)viewDidAppear:(BOOL)animated {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.