Gradingcaust: topic quality templates are being removed. Page qualities will be preserved.
Infoboxes are being rewritten. You might see images or tabs broken or behaving weirdly during the move. Infoboxes use galleries instead of tabbers now. See the source of Broot for more info.

SNCA:XML

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
This is actually... helpful?

You can read this for more info about the topic

XML (Extensible Markup Language) is a markup langauge best known for being Web 2.0. It stores data in a format readable by machines and humans. It's used for storing lists of items, configuration files and APIs. The jews have tried to replace XML with JSON (derived from JavaScript) but XML is still widely used.

Think of it as HTML but you can have it your way. HTML is not XML as HTML has predefined tags meant for web pages, whereas XML is for arbitrary data.

Basic example[edit | edit source]

<?xml version="1.0" encoding="UTF-8"?>
<wiki>
    <article>
        <title>Nophono</title>
        <summary>Nophono is a term that has three meanings. It can be used to describe a piece of boring media, content</summary>
        <views>11702</views>
        <date type="unix">1758719100</date>
    </article>
    <article>
        <title>Pepe</title>
        <summary>Pepe the Frog, also known by a few as the Grinch[1] is an organic classic best known for having</summary>
        <views>121041</views>
        <date type="unix">1644111360</date>
    </article>
</wiki>

What do i do with this .xml file?[edit | edit source]

Parse it. Many languages support XML parsing but we will use PHP for simplicity. You can also use XSLT but it isn't used much.

PHP[edit | edit source]

<?php
$xml = simplexml_load_file('wiki.xml');
?>
<HTML>
<BODY>
<TABLE>
<?php foreach ($xml->article as $article): ?>
    <TR><TH COLSPAN=2><?php echo $article->title; ?></TH></TR>
    <TR><TH>Summary</TH><TD><?php echo $article->summary; ?></TD></TR>
    <TR><TH>Views</TH><TD><?php echo $article->views; ?></TD></TR>
    <TR><TH>Date created</TH><TD><?php echo date("F j, Y, g:i a", (int)$article->date); ?></TD></TR>
<?php endforeach; ?>
</TABLE>
</BODY>
</HTML>

XSLT[edit | edit source]

Client side XML rendering without javascript. We'll assume the date isn't a unix time unlike the php version for simplicity.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="html" indent="yes" />
  <xsl:template match="/">
    <html>
      <body>
        <table>
          <xsl:for-each select="wiki/article">
            <tr>
              <th colspan="2">
                <xsl:value-of select="title"/>
              </th>
            </tr>
            <tr>
              <th>Summary</th>
              <td><xsl:value-of select="summary"/></td>
            </tr>
            <tr>
              <th>Views</th>
              <td><xsl:value-of select="views"/></td>
            </tr>
            <tr>
              <th>Date created</th>
              <td><xsl:value-of select="date"/></td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XML is part of a series on Computing

LOW LEVEL

AssemblyCC++C#Holy CRust

HIGH LEVEL

JavaGoPHPPythonSQLBashJavaScriptPowerShellActionScriptScratchRubyLua

MARKUP

HTMLCSSSVGXML

IMAGEBOARDS

nusoiVichanYotsubaOpenYotsuba

OS

WindowsLinuxAndroidTempleOS

MISC

BabybotMcChallengeSystemdMS PaintJS PaintPhotoshopFlashIRCAd blockingDark Web

AI

ChatGPTGeminiGrokVibe codingGenerative AIStable Diffusion