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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:54:57+00:00 2026-05-26T05:54:57+00:00

Completely new to using simple XML library in PHP, and have been using the

  • 0

Completely new to using simple XML library in PHP, and have been using the w3 xpath syntax for assistance.

I have an xml file that looks roughly like this:

<Xml_Configs>
<Foo_Module>
   <Front_Name>a</Front_Name>
</Foo_Module>
<Bar_Module>
   <Front_Name>b</Front_Name>
</Bar_Module>
<Baz_Module>
   <Front_Name>c</Front_Name>
</Baz_Module>
</Xml_Configs>

I’m trying to figure out which module has the Front_Name of b. Right now I’ve only been trying to get just the attribute to match, not caring about getting the parent, and here’s what I’ve tried:

$xmlObj->xpath('/Xml_Configs/*[@Front_Name="b"]');

That gets me nothing, however: “/Xml_Configs/*/Front_Name” does give me an array of simple xml objects with a, b, and c. And “/Xml_Configs/*/[@Front_Name=”b”]” gives me invalid expression errors.

Any help you can give is appreciated, thanks!

  • 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-26T05:54:57+00:00Added an answer on May 26, 2026 at 5:54 am

    I’m trying to figure out which module has the Front_Name of b

        `$xmlObj->xpath('/Xml_Configs/*[@Front_Name="b"]');`
    
     That gets me nothing
    

    Yes, because none of the elements that are children of the top element Xml_Configs have any attributes.

    You want:

    /*/*[Front_Name = 'b']
    

    This selects all children of the top element that have a child named Font_Name with string value "b".

    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="/*/*[Front_Name = 'b']"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the provided XML document:

    <Xml_Configs>
        <Foo_Module>
            <Front_Name>a</Front_Name>
        </Foo_Module>
        <Bar_Module>
            <Front_Name>b</Front_Name>
        </Bar_Module>
        <Baz_Module>
            <Front_Name>c</Front_Name>
        </Baz_Module>
    </Xml_Configs>
    

    it copies to the output the selected node:

    <Bar_Module>
       <Front_Name>b</Front_Name>
    </Bar_Module>
    

    I would recommend that you obtain the XPath Visualizer — a tool that has helped thousands of developers learn XPath while having fun at the same time.

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

Sidebar

Related Questions

I'm using a new no-name framework that I'm not completely familiar with and I'm
I have a bit of Java code that outputs an XML file to a
I'm completely new to TeamCity and I'm using a simple Visual Studio 2008 solution
I have an RSS feed that I'm setting up on my new site using
I'm completely new to Oracle's XDB, in particular using it to generate XML output
Guys i am very new to jQuery. I have started using the auto complete
I am completely new to LINQ in C#/.NET. I understand that I could use
Hopefully this will be a simple fix. I'm completely new to XSL but I've
I'm trying to post-process the documentation XML file as a post-build XSLT transformation (using
I'm new to Python completely and am using Python 3.1 on Windows (pywin). 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.