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 514627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:32:40+00:00 2026-05-13T07:32:40+00:00

After giving up on PHP I’m trying to extract data from the xml using

  • 0

After giving up on PHP I’m trying to extract data from the xml using XSLT

How do i match the data in <jskit:attribute key="permalink"

I saw another similar question about name value pairs but im one step away from that

My xml is given here xml source

  • 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-05-13T07:32:41+00:00Added an answer on May 13, 2026 at 7:32 am

    First, make sure that all namespaces you want to use are available in the xslt. For example, define xmlns prefixes for all of them in the top element, like so:

    <?xml version="1.0" encoding="ISO-8859-1"?> 
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:jskit="http://purl.org/dc/elements/1.1/"
    >
        ... xslt templates go here...
    </xsl:stylesheet>
    

    After that, you can use the namespace prefix jskit in your XPath expressions.

    <?xml version="1.0" encoding="ISO-8859-1"?> 
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:jskit="http://purl.org/dc/elements/1.1/"
    >
        <!-- match all items anywhere in the document -->
        <xsl:template match="//item">
             <!-- get the "value" attribute of the "jskit:attribute" element 
                  in the current item in case the "key" attribute is called "permalink"
             --> 
             <xsl:value-of select="jskit:attribute[@key='permalink']/@value"/>
             , <!-- comma separator, literal txt -->             
             <!-- get the "value" attribute of the "jskit:attribute" element 
                  in the current item in case the "key" attribute is called "IP"
             --> 
             <xsl:value-of select="jskit:attribute[@key='IP']/@value"/>    
        </xsl:template>
    </xsl:stylesheet>
    

    The templates and XPath you need to write are completely dependent on the requirements of your desired output format and this is not easy to answer in full if we lack that nformation

    But let’s say you want to insert the data into a database, you could then generate SQL statements directly with XSLT:

    <?xml version="1.0" encoding="ISO-8859-1"?> 
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:jskit="http://purl.org/dc/elements/1.1/"
    >
        <!-- make text output (SQL script) -->
        <xsl:output
            method="text"
        />
    
        <!-- match all items anywhere in the document -->
        <xsl:template match="//item">
             INSERT INTO myTable(permalink, IP) VALUES
             ('<xsl:value-of select="jskit:attribute[@key='permalink']/@value"/>'
             ,'<xsl:value-of select="jskit:attribute[@key='IP']/@value"/>');
        </xsl:template>
    </xsl:stylesheet>
    

    However, to make this kind of thing really robust, you have to make sure that the values that end up in the SQL statement don’t contain any string delimiter. If for example the permalink could contain a single quote, then this would generate invalid SQL as the single quote from the value would prematurely end the string literal SQL value.

    To counter that, you can write a template that recursively processes the text values to escape those characters that need it (apart from the quote and depending on your database you may need to escape other characters too)

    Anothter approach would be to use the XSLT to convert the data to a format you can easily parse in your host language. Say you are using PHP, then you ucould use XSLT to convert the XML to ini file format, parse that with parse_ini_file(), and then use PHP to properly escape/validate values and then perform the database actions.

    YMMV

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

Sidebar

Related Questions

using PHP Version 5.3.5 I am going insane. This piece of code is giving
I took this basic upload file script from php.net and it is giving two
was trying to finish a script in jquery and I was stuck. after giving
I have been trying to create a simple calculator. Using PHP I managed to
I seem to stumble on problem after problem giving my entities behaviour. I have
I am running valgrind as follows:- /usr/local/bin/valgrind process_name After excecution its giving me following
After hours I am giving up on debugging the following: This works: URL[] urls
I was writing a script that kept giving me errors. After tracking it down
I putting wmd on my website. After putting code in and giving it a
Here's a strange one. After renaming a class, one of my forms began giving

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.