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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:44:45+00:00 2026-06-17T22:44:45+00:00

Possible Duplicate: Fetch specific tag with an attribute value from XML I have a

  • 0

Possible Duplicate:
Fetch specific tag with an attribute value from XML

I have a XML file like the following:

<?xml version="1.0" encoding="UTF-8"?>
<response uri="/crm/private/xml/SalesOrders/getRecords">
    <result>
        <SalesOrders>
            <row no="1">
                <FL val="SALESORDERID">580005000000187001</FL>
                <FL val="SO Number"><![CDATA[580005000000187002]]></FL>
                <FL val="Subject"><![CDATA[Sales order test from sri 02]]></FL>
                <FL val="Due Date"><![CDATA[2013-03-10]]></FL>
                <FL val="Status"><![CDATA[Created]]></FL>
                <FL val="ACCOUNTID">580005000000088096</FL>
                <FL val="Account Name"><![CDATA[Best Western Pavilions]]></FL>
                <FL val="SMOWNERID">580005000000052003</FL>
                <FL val="Sales Order Owner"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="SMCREATORID">580005000000052003</FL>
                <FL val="Created By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="MODIFIEDBY">580005000000052003</FL>
                <FL val="Modified By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="Created Time"><![CDATA[2013-01-17 20:32:19]]></FL>
                <FL val="Modified Time"><![CDATA[2013-01-17 20:32:19]]></FL>
                <FL val="Sub Total"><![CDATA[250]]></FL>
                <FL val="Tax"><![CDATA[0]]></FL>
                <FL val="Adjustment"><![CDATA[0]]></FL>
                <FL val="Grand Total"><![CDATA[250]]></FL>
                <FL val="Product Details">
                    <product no="1">
                        <FL val="Product Id">580005000000171125</FL>
                        <FL val="Product Name"><![CDATA[The Grilling Maestro]]></FL>
                        <FL val="Unit Price">10.0</FL>
                        <FL val="Quantity">20.0</FL>
                        <FL val="Quantity in Stock">0.0</FL>
                        <FL val="Total">200.0</FL>
                        <FL val="Discount">0.0</FL>
                        <FL val="Total After Discount">200.0</FL>
                        <FL val="List Price">10.0</FL>
                        <FL val="Net Total">200.0</FL>
                        <FL val="Tax">0.0</FL>
                        <FL val="Product Description"><![CDATA[null]]></FL>
                    </product>
                    <product no="2">
                        <FL val="Product Id">580005000000171131</FL>
                        <FL val="Product Name"><![CDATA[Uptown Deli   Soup du Jour]]></FL>
                        <FL val="Unit Price">25.0</FL>
                        <FL val="Quantity">1.0</FL>
                        <FL val="Quantity in Stock">0.0</FL>
                        <FL val="Total">50.0</FL>
                        <FL val="Discount">1.23</FL>
                        <FL val="Total After Discount">23.77</FL>
                        <FL val="List Price">25.0</FL>
                        <FL val="Net Total">48.77</FL>
                        <FL val="Tax">0.0</FL>
                        <FL val="Product Description"><![CDATA[null]]></FL>
                    </product>
                </FL>
                <FL val="Terms and Conditions"><![CDATA[iBanquet T and C]]></FL>
                <FL val="Description"><![CDATA[Sales Order from iBanquet]]></FL>
                <FL val="Discount"><![CDATA[0]]></FL>
            </row>
            <row no="2">
                <FL val="SALESORDERID">580005000000134001</FL>
                <FL val="SO Number"><![CDATA[580005000000134003]]></FL>
                <FL val="Subject"><![CDATA[Test]]></FL>
                <FL val="CONTACTID">580005000000120009</FL>
                <FL val="Contact Name"><![CDATA[Sydney Lai]]></FL>
                <FL val="Carrier"><![CDATA[FedEX]]></FL>
                <FL val="Excise Duty"><![CDATA[0]]></FL>
                <FL val="Sales Commission"><![CDATA[0]]></FL>
                <FL val="Status"><![CDATA[Created]]></FL>
                <FL val="ACCOUNTID">580005000000088100</FL>
                <FL val="Account Name"><![CDATA[Best Western Sportstown Anaheim]]></FL>
                <FL val="SMOWNERID">580005000000052003</FL>
                <FL val="Sales Order Owner"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="SMCREATORID">580005000000052003</FL>
                <FL val="Created By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="MODIFIEDBY">580005000000052003</FL>
                <FL val="Modified By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="Created Time"><![CDATA[2012-11-08 14:51:50]]></FL>
                <FL val="Modified Time"><![CDATA[2012-11-08 14:51:50]]></FL>
                <FL val="Sub Total"><![CDATA[45]]></FL>
                <FL val="Tax"><![CDATA[0]]></FL>
                <FL val="Adjustment"><![CDATA[0]]></FL>
                <FL val="Grand Total"><![CDATA[45]]></FL>
                <FL val="Product Details">
                    <product no="1">
                        <FL val="Product Id">580005000000059016</FL>
                        <FL val="Product Name"><![CDATA[Beef Stoganoff]]></FL>
                        <FL val="Unit Price">14.95</FL>
                        <FL val="Quantity">1.0</FL>
                        <FL val="Quantity in Stock">-25.0</FL>
                        <FL val="Total">45.0</FL>
                        <FL val="Discount">0.0</FL>
                        <FL val="Total After Discount">45.0</FL>
                        <FL val="List Price">45.0</FL>
                        <FL val="Net Total">45.0</FL>
                        <FL val="Tax">0.0</FL>
                        <FL val="Product Description"><![CDATA[null]]></FL>
                    </product>
                </FL>
                <FL val="Discount"><![CDATA[0]]></FL>
            </row>
            <row no="3">
                <FL val="SALESORDERID">580005000000118001</FL>
                <FL val="SO Number"><![CDATA[580005000000118003]]></FL>
                <FL val="Subject"><![CDATA[SAirpriya's Birthday]]></FL>
                <FL val="POTENTIALID">580005000000069001</FL>
                <FL val="Potential Name"><![CDATA[Sandeep]]></FL>
                <FL val="Due Date"><![CDATA[2012-10-17]]></FL>
                <FL val="Carrier"><![CDATA[FedEX]]></FL>
                <FL val="Excise Duty"><![CDATA[0]]></FL>
                <FL val="Sales Commission"><![CDATA[0]]></FL>
                <FL val="Status"><![CDATA[Created]]></FL>
                <FL val="ACCOUNTID">580005000000088090</FL>
                <FL val="Account Name"><![CDATA[Best Western Anaheim Inn]]></FL>
                <FL val="SMOWNERID">580005000000052003</FL>
                <FL val="Sales Order Owner"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="SMCREATORID">580005000000052003</FL>
                <FL val="Created By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="MODIFIEDBY">580005000000052003</FL>
                <FL val="Modified By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="Created Time"><![CDATA[2012-10-16 14:45:18]]></FL>
                <FL val="Modified Time"><![CDATA[2012-10-16 14:45:18]]></FL>
                <FL val="Sub Total"><![CDATA[1080]]></FL>
                <FL val="Tax"><![CDATA[0]]></FL>
                <FL val="Adjustment"><![CDATA[0]]></FL>
                <FL val="Grand Total"><![CDATA[1080]]></FL>
                <FL val="Product Details">
                    <product no="1">
                        <FL val="Product Id">580005000000059016</FL>
                        <FL val="Product Name"><![CDATA[Beef Stoganoff]]></FL>
                        <FL val="Unit Price">14.95</FL>
                        <FL val="Quantity">24.0</FL>
                        <FL val="Quantity in Stock">-25.0</FL>
                        <FL val="Total">1080.0</FL>
                        <FL val="Discount">0.0</FL>
                        <FL val="Total After Discount">1080.0</FL>
                        <FL val="List Price">45.0</FL>
                        <FL val="Net Total">1080.0</FL>
                        <FL val="Tax">0.0</FL>
                        <FL val="Product Description"><![CDATA[null]]></FL>
                    </product>
                </FL>
                <FL val="Discount"><![CDATA[0]]></FL>
            </row>
            <row no="4">
                <FL val="SALESORDERID">580005000000070009</FL>
                <FL val="SO Number"><![CDATA[580005000000070011]]></FL>
                <FL val="Subject"><![CDATA[iBanquet]]></FL>
                <FL val="QUOTEID">580005000000070003</FL>
                <FL val="Quote Name"><![CDATA[iBanquet]]></FL>
                <FL val="Carrier"><![CDATA[UPS]]></FL>
                <FL val="Excise Duty"><![CDATA[0]]></FL>
                <FL val="Sales Commission"><![CDATA[0]]></FL>
                <FL val="Status"><![CDATA[Created]]></FL>
                <FL val="ACCOUNTID">580005000000058001</FL>
                <FL val="Account Name"><![CDATA[Hotel Skysurf]]></FL>
                <FL val="SMOWNERID">580005000000052003</FL>
                <FL val="Sales Order Owner"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="SMCREATORID">580005000000052003</FL>
                <FL val="Created By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="MODIFIEDBY">580005000000052003</FL>
                <FL val="Modified By"><![CDATA[Adithya Buddhavarapu]]></FL>
                <FL val="Created Time"><![CDATA[2012-06-19 19:17:12]]></FL>
                <FL val="Modified Time"><![CDATA[2012-06-29 19:55:00]]></FL>
                <FL val="Sub Total"><![CDATA[20538]]></FL>
                <FL val="Tax"><![CDATA[0]]></FL>
                <FL val="Adjustment"><![CDATA[0]]></FL>
                <FL val="Grand Total"><![CDATA[20538]]></FL>
                <FL val="Product Details">
                    <product no="1">
                        <FL val="Product Id">580005000000059032</FL>
                        <FL val="Product Name"><![CDATA[Carrot Cake]]></FL>
                        <FL val="Unit Price">10.0</FL>
                        <FL val="Quantity">441.0</FL>
                        <FL val="Quantity in Stock">-882.0</FL>
                        <FL val="Total">4410.0</FL>
                        <FL val="Discount">0.0</FL>
                        <FL val="Total After Discount">4410.0</FL>
                        <FL val="List Price">10.0</FL>
                        <FL val="Net Total">4410.0</FL>
                        <FL val="Tax">0.0</FL>
                        <FL val="Product Description"><![CDATA[null]]></FL>
                    </product>
                    <product no="2">
                        <FL val="Product Id">580005000000059022</FL>
                        <FL val="Product Name"><![CDATA[Chicken Parmigiano]]></FL>
                        <FL val="Unit Price">15.0</FL>
                        <FL val="Quantity">122.0</FL>
                        <FL val="Quantity in Stock">-122.0</FL>
                        <FL val="Total">1464.0</FL>
                        <FL val="Discount">0.0</FL>
                        <FL val="Total After Discount">1464.0</FL>
                        <FL val="List Price">12.0</FL>
                        <FL val="Net Total">1464.0</FL>
                        <FL val="Tax">0.0</FL>
                        <FL val="Product Description"><![CDATA[null]]></FL>
                    </product>
                    <product no="3">
                        <FL val="Product Id">580005000000059030</FL>
                        <FL val="Product Name"><![CDATA[Coconut Cake]]></FL>
                        <FL val="Unit Price">10.0</FL>
                        <FL val="Quantity">1222.0</FL>
                        <FL val="Quantity in Stock">-1222.0</FL>
                        <FL val="Total">14664.0</FL>
                        <FL val="Discount">0.0</FL>
                        <FL val="Total After Discount">14664.0</FL>
                        <FL val="List Price">12.0</FL>
                        <FL val="Net Total">14664.0</FL>
                        <FL val="Tax">0.0</FL>
                        <FL val="Product Description"><![CDATA[null]]></FL>
                    </product>
                </FL>
                <FL val="Discount"><![CDATA[0]]></FL>
            </row>
        </SalesOrders>
    </result>
</response>

I need to show the name of the sales order owner name and their associated product name which is stored under <FL val="Product Name"> of product tag.

My code is like:

$file_sales_content = "https://crm.zoho.com/crm/private/xml/SalesOrders/getRecords?authtoken=XXX&scope=crmapi"  
$doc = new DOMDocument();
$doc->loadXML( $file_sales_content );   
$xpath = new DOMXPath( $doc );
$items = $xpath->evaluate( '//FL[@val="Sales Order Owner"]' );
$sales_order_array = array();
for ( $i = 0; $i < $items->length; $i++ ) {
 array_push($sales_order_array,$items->item( $i )->textContent);
}

where $file_sales_content returns the above xml.

But I think some shortcut method is there. If so please help me.

Thanks in advance.

  • 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-17T22:44:47+00:00Added an answer on June 17, 2026 at 10:44 pm

    I’d suggest setting up your code like this:

    $file_sales_content = "https://crm.zoho.com/crm/private/xml/SalesOrders/getRecords?authtoken=XXX&scope=crmapi"  
    $doc = new DOMDocument();
    $doc->loadXML( $file_sales_content );   
    $xpath = new DOMXPath( $doc );
    $items = $xpath->evaluate( '//FL[@val="Sales Order Owner"]' );
    $sales_orders = array();
    foreach ( $items as $item) {
        $sales_order = array();
        $sales_order['name'] = $item->textContent;
    
        $products = array();
        $childItems = $xpath->evaluate( '../FL/product/FL[@val = "Product Name"]', $item );
        foreach( $childItems as $productName) {
           $products[] = $productName->textContent;
        }       
        $sales_order['product'] = $products;
        $sales_orders[] = $sales_order;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: read XML tag id from php what is the way to fetch
Possible Duplicate: How to fetch result from MySQL row with multiple same-name columns with
Possible Duplicate: Android image view from url I am trying to fetch the image
Possible Duplicate: Fetch all Images from Android Photo Gallery I want to fetch id
Possible Duplicate: in_array() and multidimensional array Got the following array returned from a database
Possible Duplicate: Is is possible to set a default PDO fetch mode? I have
Possible Duplicate: how to delete item from listView? I fetch data from Database in
Possible Duplicate: Merge two rows in SQL I have the following values in table:
Possible Duplicate: Fetch the row which has the Max value for a column My
Possible Duplicate: Fetch the row which has the Max value for a column I

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.