Example - xml creator

XML output retrieves today's national, regional and global weather from homepage of uk.weather.com. Output is refreshing each 15 minutes from cron.

 

 

Output:

<?xml version="1.0" encoding="UTF-8"?>
<wordpress>
  <data title="WordPress Themes">
    <theme>
      <name>Libre 2</name>
      <description>A stylish, classic look for your personal blog or long-form writing site. The main navigation bar stays fixed to the top while your visitors read, keeping your most important content at hand, while three footer widget areas give your secondary content a comfortable home.</description>
      <demo_url>https://libre2demo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Maxwell</name>
      <description>Maxwell is a modern blog theme with an ultra clean and elegant design. With its beautiful typography and thoughtful white space, Maxwell truly helps you to stand out with your content.</description>
      <demo_url>https://maxwelldemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Lenscap</name>
      <description>Lenscap makes it super easy to create a stunning WordPress-powered magazine and online store with slick content discovery features, gallery and video post styles, smart customization options and WooCommerce support.</description>
      <demo_url>https://lenscapdemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Ixion</name>
      <description>A theme for non-profits, organizations, and schools.</description>
      <demo_url>https://ixiondemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Wanderer</name>
      <description>A blogging theme.</description>
      <demo_url>https://wandererdemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Eris</name>
      <description>Eris is a crisp and elegant portfolio theme. You can use showcase all your different projects as a unified and beautiful story.</description>
      <demo_url>https://erisdemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Carbon</name>
      <description>A WordPress theme with Versatile Layout</description>
      <demo_url>https://carbonthemedemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Karuna</name>
      <description>Karuna is a clean business theme designed with health and wellness-focused sites in mind. With bright, bold colors, prominent featured images, and support for customer testimonials, your business&amp;amp;#8217; brand will shine with Karuna.</description>
      <demo_url>https://karunademo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Twenty Sixteen</name>
      <description>Twenty Sixteen is a modernized take on an ever-popular WordPress layout — the horizontal masthead with an optional right sidebar that works perfectly for blogs and websites. It has custom color options with beautiful default color schemes, a harmonious fluid grid using a mobile-first approach, and impeccable polish in every detail. Twenty Sixteen will make your WordPress look beautiful everywhere.</description>
      <demo_url>https://twentysixteendemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Label</name>
      <description>Label is a stylistic theme created specially for art and fashion bloggers. With a distinctive masonry powered layout, a fullscreen post slider, and a classy vertical header &amp;amp;#8211; it&amp;amp;#8217;s sure to make your website stand out.</description>
      <demo_url>https://labeldemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Shoreditch</name>
      <description>Shoreditch is a functional and responsive theme perfect for your business’s online presence. Although its main purpose is business, Shoreditch looks great as a personal blog theme too.</description>
      <demo_url>https://shoreditchdemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Affinity</name>
      <description>Affinity is a classic one-page theme designed with weddings and family announcements in mind.</description>
      <demo_url>https://affinitydemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Ippo</name>
      <description>Ippo is a clean, responsive theme for all creatives, especially interior designers and fashion bloggers. Ippo puts your photos and lifestyle mood boards front and center.</description>
      <demo_url>https://ippodemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Pena</name>
      <description>This theme has been inspired by &amp;amp;#8220;Living on One Dollar&amp;amp;#8221; documentary we watched one night. We were deeply touched and wanted to somehow contribute to the whole project. As theme developers we decided to develop a WordPress theme to help spread the word about it. Pena is modern, responsive and mobile friendly theme.</description>
      <demo_url>https://penademo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Sapor</name>
      <description>Sapor is a two column blogging theme with a lot of possibilities</description>
      <demo_url>https://sapordemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Button</name>
      <description>A stylish, lighthearted theme for crafters, hobbyists, and creatives.</description>
      <demo_url>https://buttondemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Edin</name>
      <description>Edin is a modern responsive business and corporate theme that helps you to create a strong&amp;amp;#8211;yet beautiful&amp;amp;#8211;online presence for your business.</description>
      <demo_url>https://edindemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Carmack</name>
      <description>Carmack is a magazine theme, designed primarily for car magazines &amp;amp;#8211; but equally usable for Video Games, Movies, Music or any other visual magazine style site. Carmack supports featured content and post formats to allow you to create the perfect website.</description>
      <demo_url>https://carmackdemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Rosalie</name>
      <description>Rosalie is an elegant, minimalistic and responsive modern WordPress theme built specifically for bloggers who love craft, lifestyle, fashion and generally are cool people. Designed for WordPress.com.</description>
      <demo_url>https://rosaliedemo.wordpress.com/</demo_url>
    </theme>
    <theme>
      <name>Gateway</name>
      <description>Gateway is the perfect mix of class and elegance, a traditional yet customizable home for your content. Reinforce your brand with a site logo, add a bold header image and call to action, and showcase your best posts or a video with a special Homepage template.</description>
      <demo_url>https://gatewaydemo.wordpress.com/</demo_url>
    </theme>
  </data>
</wordpress>

Source code of script:

# File: xmlcreator_main.w
# Name: XML Creator for data about Wordpress Themes
# Description: Script extracts basic information about the most popular Wordpress Themes and saves extracted data into XML file.
# Input: URL
# Output format: XML
# Output fields: Theme name, description, demo URL

#<Logger File>
#	Global
#	FileName xmlcreator_log.log
#	Level debug
#</Logger>

<Section>
	Name xmlcreator_main
			
	Define $output_file xmlcreator_output.xml

	
	
	#delete old output CSV file
	<Action Exec>
		cmd rm -f *.xml
	</Action>
	
	
	
    # load content    
    <Action ContentURL>
        URL https://wordpress.com/themes/
        RemoveNewLine
    </Action>
	
	# inicializing of XML structure
	<Action Php>
		Code $context->setVariable('$dom', createXML());
	</Action>

	<Pattern>
		RegExp <h2>{$title_tag}</h2>
		Compact
		Trim
	</Pattern>

	# add title to structure
	<Action Php>
		Code $context->setVariable('$dom', addTitleToXML($context->getVariable('$dom'),$context));
	</Action>

	<Section While>
		Optional
		# Finish extraction at the end of themes' list
		EndAt <nav id="nav-below"
		
		<Pattern>
			RegExp <header class="entry-header">
		</Pattern>
		
		# Restrict  processed content to current theme information, so we will not skip to another one
		<Section>
			EndAt </header>
			
			<Pattern>
				Optional
				RegExp <h1 class="entry-title"><a class="details" href="{:re([^"]*)}" title="{$description:re([^"]*)}">{$name}</a></h1>
				Compact
				Trim
			</Pattern>
			
			<Pattern>
				Optional
				RegExp <a class="preview" href="{$demo_url:re([^"]*)}" target="_blank">Demo</a>
				Compact
				Trim
			</Pattern>
			
			# add data from this section iteration to structure
			<Action Php>
				Code $context->setVariable('$dom', addThemeToXML($context->getVariable('$dom'),$context));
			</Action>
		</Section>		
	</Section>

	# save whole XML structure to output file
	<Action Php>
		Code saveXML($context->getVariable('$dom'),$context->getVariable('$output_file'));
	</Action>
</Section>	

Main xmlcreator_main