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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:58:30+00:00 2026-06-08T05:58:30+00:00

I am attempting to use xpath to run a program and parse out xml

  • 0

I am attempting to use xpath to run a program and parse out xml data for repricing books. However, when I run the program I get the following errors:

PHP Warning:  SimpleXMLElement::xpath() [<a href='simplexmlelement.xpath'>simplexmlelement.xpath</a>]: Invalid expression

and

PHP Warning:  SimpleXMLElement::xpath() [<a href='simplexmlelement.xpath'>simplexmlelement.xpath</a>]: xmlXPathEval: evaluation failed

both on line 242 which is the line of $result…:

//function to check if child nodes exist for pricing
function xml_child_exists($xml, $childpath)
 {
$result = $xml->xpath($childpath);
 if (isset($result)) {
    return true;
} else {
    return false;
}

}

This function is run here:

// check to see if there are values
        if(xml_child_exists($parsed_xml, $current->AttributeSets->children('ns2', true)->ItemAttributes->ListPrice->Amount))
           { 
            $listPrice = $current->AttributeSets->children('ns2', true)->ItemAttributes->ListPrice->Amount;
          } else {
            $listPrice = 0;
          }

Then I finally am ending up with:

PHP Fatal error:  Call to a member function children() on a non-object in repricemws.php on line 67

Line 67 is where the function is being called.

What is wrong with this code and how do I make it so that it will run correctly?

  • 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-08T05:58:33+00:00Added an answer on June 8, 2026 at 5:58 am

    Does $current->AttributeSets->children('ns2', true)->ItemAttributes->ListPrice->Amount contain a valid XPath expression?

    From the looks of that call chain, you’re pulling out a single value, e.g. ‘5.00’ and passing that directly to the xpath query executor. That’s not going to work, and produce your error messages.


    followup:

    ok, so Amount is a price, so it’s something like $5.00 or 5.00, right? That means you’re using that exact string as your xpath query, basically doing:

    $result = $xml->xpath('$5.00');
    

    That is NOT a valid xpath expression. So $result is NOT a list of matching nodes in the document, it’s actually going to be a boolean FALSE.

    You then do an isset() on that value. The variable IS set (to boolean false), so your function returns TRUE.

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

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
I am attempting to use the data sources pluigin for rubymine 4.0.3 but I
I am attempting to use the following code to search a database using words
Attempting to use the amazon API to obtain product data and currently failing miserably.
I'm attempting to use the new Storyboard feature, however I am confused about Storyboard
I am attempting to use an Intent Service to run in the background to
Attempting to use a custom hex color for my css triangle (border). However since
I am attempting to use the MediaStore.ACTION_VIDEO_CAPTURE in my app, see code below. However,
I am attempting to use PHP to edit the DOM document tree. However, I
I'm attempting to use the following code to serialize an anonymous type to JSON:

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.