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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:48:36+00:00 2026-05-16T23:48:36+00:00

I have an XML feed that looks like this: <?xml version=1.0 encoding=UTF-8?> <productFeed version=1.0

  • 0

I have an XML feed that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<productFeed version="1.0" timestamp="20100910:04:06:55">
<product id="196">
    <name>Lorem</name>
    <price>190.00</price>
    <description>Lorem Ipsum</description>
    <productURL> http://www.example.com</productURL>
    <imageURL> http://www.example.com/lorem.jpg </imageURL>
    <additional>
        <field name="country" value="IT" />
        <field name="region" value="Rome" />
        <field name="city" value="Rome" />
    </additional>
    <categories>
        <category name="foobar" />
    </categories>
</product> 
</productFeed>

I’m trying to print out the category attribute, among other things with this script:

<?php
$url = 'lorem.xml';
$xml = simplexml_load_file($url);
$expr = "/productFeed//product/additional/field[@value='Rome']/parent::*/parent::*";
$result = $xml->xpath($expr);

foreach($result as $item) {
    echo $item->name;
    echo $item->imageURL;
    echo $item->description;
    echo $item->price;
    echo $item->category->attributes()->name;
}

This produces a:

Warning: main() [function.main]: Node no longer exists

error although the FireXPath Firebug plugin tells me I’m correctly selecting the attributes too.

  • 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-16T23:48:37+00:00Added an answer on May 16, 2026 at 11:48 pm

    You have a typo!

    Its:

    echo $item->categories->category->attributes()->name;

    Not:

    echo $item->category->attributes()->name;

    For everything:

    foreach($result as $item) {
      echo $item->name;
      echo $item->imageURL;
      echo $item->description;
      echo $item->price;
      echo $item->category->attributes()->name;
        foreach($item->additional->field as $field)
        {
            echo $field["name"];
            echo $field["value"];
        }
    }
    
    
    

    Good Luck

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

Sidebar

Related Questions

I have XML shaped like the following: <?xml version=1.0 encoding=UTF-8?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:openSearch=http://a9.com/-/spec/opensearch/1.1/ xmlns:docs=http://schemas.google.com/docs/2007
I have an XML feed that looks something like this: I can parse the
I have a feed.xml file that looks something like this. What I want to
I have converted a table as an xml string that looks something like <NewDataSet>\r\n
I have an XML feed that I've retrieved via httpwebrequest, and I'm having problems
I have this script to generate an XML file for an RSS feed. Works
I have a client that sends an xml feed which I parse using the
I have an XML feed of events whose dates I would like to interact
I have a cron job scrape.sh that look like this: #!/bin/bash touch rage cd
I have a XML feed of products that I break down into smaller XML

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.