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

The Archive Base Latest Questions

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

I am getting this error, Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: Invalid expression . Searched in internet

  • 0

I am getting this error,

Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: Invalid expression.

Searched in internet but could not remove this error. That is im posting it one more time.

Here is my php code:

<?php
            $file = $_POST['id'];
            $xml = simplexml_load_file('test.xml');

            $user = $xml->xpath("user[user_id == $id]");             
            $name = $user->name;
            $file = $user->file;
            echo 'Name' . $name;
            echo 'File Name' . $file;
?>
        <form action='<?php echo $_SERVER['PHP_SELF']?>' method="POST">
            Login ID: <input type="text" name="id" />
            <input type="submit" name="submit" value="Submit"/>               
        </form> 

And my test.xml file is:

<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
    <user>
        <user_id>0121</user_id>
        <name>Tim</name>
        <file>0121.file</file>
    </user>
    <user>
        <user_id>0178</user_id>
        <name>Henry</name>
        <file>0178.file</file>
    </user>
    <user>
        <user_id>0786</user_id>
        <name>Martin</name>
        <file>0786.file</file>
    </user>
    <user>
        <user_id>1239</user_id>
        <name>Jan</name>
        <file>1239.file</file>
    </user>
</document>

Any reason?

Thanks
Raaks

  • 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-26T23:36:21+00:00Added an answer on May 26, 2026 at 11:36 pm

    == is the invalid expression. Try this:

     $user = $xml->xpath("user[user_id=$id]");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this error: Warning: Invalid argument supplied for foreach() in [page].php on line
I'm using a variable to create an element. But I'm getting this error: Warning:
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
am getting this error when i open my site in internet explorer......... plz help
I am getting this error now that I hit version number 1.256.0: Error 4
I am getting this error when trying to run internet information services on a
I am getting this error but only very occasionally. 99.9% of the time it
I'm getting this odd error in the preg_match() function: Warning: preg_match(): Compilation failed: range
I am trying to figure why I am getting this error. **Warning: require_once(\C\wamp\www\PHP with
I'm getting this error: Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home1/host/public_html/employee/message/config.php on line

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.