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

  • Home
  • SEARCH
  • 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 8315303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:06:07+00:00 2026-06-08T21:06:07+00:00

How i get specific data only Kod attribute is USD and GBP on xml

  • 0

How i get specific data only Kod attribute is USD and GBP on xml file?Is there a method for fetching attribute value?

TODAY.XML:

<?xml version="1.0" encoding="iso-8859-9"?>
    <Tarih_Date Tarih="27.07.2012" Date="07/27/2012">
        <Currency Kod="USD" CurrencyCode="USD">
            <CurrencyName>US DOLLAR</CurrencyName>
            <ForexBuying>1.81</ForexBuying>
            <ForexSelling>1.8187</ForexSelling>
        </Currency>
        <Currency Kod="EUR" CurrencyCode="EUR">
            <CurrencyName>EURO</CurrencyName>
            <ForexBuying>2.2227</ForexBuying>
            <ForexSelling>2.2334</ForexSelling>
        </Currency>
        <Currency Kod="GBP" CurrencyCode="GBP">
            <CurrencyName>POUND STERLING</CurrencyName>
            <ForexBuying>2.841</ForexBuying>
            <ForexSelling>2.8559</ForexSelling>
        </Currency>
    </Tarih_Date>

PHP:

<?php
    $get_url = "today.xml";
    $xml = simplexml_load_file($get_url) or die("Error : Cannot create object!");

    foreach($xml-> Currency as $currency){
         //$attr = $currency -> attributes();
         echo $attr."<br/>";
         //echo $currency -> CurrencyName;
        //echo $data -> CurrencyName ."-". $data -> ForexBuying ."-". $data -> ForexSelling ."<br/>";
    }
?>
  • 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-08T21:06:08+00:00Added an answer on June 8, 2026 at 9:06 pm

    Use an XPath expression like this::

    /*/*[@Kod = 'USD' or @Kod = 'GBP']/*
    

    This selects any element that is a grand-child of the top element of the XML document, and its parent’s Kod attribute has string value either "USD" or "GBP".

    Or use:

    /*/*[@Kod = 'USD' or @Kod = 'GBP']/*/text()
    

    This selects the text-node children of the elements selected in the previous XPath expression.

    XSLT-based verification:

    <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="/">
         <xsl:copy-of select="/*/*[@Kod = 'USD' or @Kod = 'GBP']/*"/>
    ===========
         <xsl:copy-of select="/*/*[@Kod = 'USD' or @Kod = 'GBP']/*/text()"/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <Tarih_Date Tarih="27.07.2012" Date="07/27/2012">
        <Currency Kod="USD" CurrencyCode="USD">
            <CurrencyName>US DOLLAR</CurrencyName>
            <ForexBuying>1.81</ForexBuying>
            <ForexSelling>1.8187</ForexSelling>
        </Currency>
        <Currency Kod="EUR" CurrencyCode="EUR">
            <CurrencyName>EURO</CurrencyName>
            <ForexBuying>2.2227</ForexBuying>
            <ForexSelling>2.2334</ForexSelling>
        </Currency>
        <Currency Kod="GBP" CurrencyCode="GBP">
            <CurrencyName>POUND STERLING</CurrencyName>
            <ForexBuying>2.841</ForexBuying>
            <ForexSelling>2.8559</ForexSelling>
        </Currency>
    </Tarih_Date>
    

    the two XPath expressions are evaluated and the results of this evaluation are copied to the output:

    <CurrencyName>US DOLLAR</CurrencyName>
    <ForexBuying>1.81</ForexBuying>
    <ForexSelling>1.8187</ForexSelling>
    <CurrencyName>POUND STERLING</CurrencyName>
    <ForexBuying>2.841</ForexBuying>
    <ForexSelling>2.8559</ForexSelling>
    ===========
         US DOLLAR1.811.8187POUND STERLING2.8412.8559
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get specific parts of a String like: @org.junit.runners.Suite$SuiteClasses(value=[class data.XTest , class
Is there a way to get a specific column / property of data e.g.
I am trying to get the specific value of file extension in this array.
I'm trying to get a specific value from a mysql_fletch_assoc array. I explain. Here
Is there a way to get a specific element (based in index) from a
Is there a way to get a specific field name from a template with
How can I make this get a specific users data, Example user enters his
Possible Duplicate: way to get specific integer(s) from a double data type C++ So
I want to create a class that accepts data only in a specific format,
I have CSV data file contained follow info: -0.2500000000,15, 15;15;15;15;15;15;15;15;15;15;15;15;15;15;15;15;15;0;0;0;0;0;15;0;0 ,0,0 I only want

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.