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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:20:17+00:00 2026-05-27T06:20:17+00:00

I have an XML file filled with ‘producers.’ Here is a sample of what

  • 0

I have an XML file filled with ‘producers.’

Here is a sample of what the file looks like:

<producer>
   <name>John Doe's Fish Emporium!</name>
   <owner>John Doe</owner>
   <address>
      <civic>123</civic>
      <mailing>Example Drive</mailing>
      <town>Halifax</town>
      <province>Nova Scotia</province>
      <postal>A1B 2C3</postal>
      <phone>902-123-4567</phone>
      <fax>902-098-7654</fax>
      <email>john@example.com</email>
      <website>www.example.com</website>
   </address>
   <products>
      <product>Pollock (Saithe)</product>
      <product>Flounder/Sole</product>
      <product>Salmon, Farm Raised</product>
      <product>Mussels, Blue</product>
   </products>
   <exports>
      <region>Europe</region>
      <region>North America</region>
      <region>Pacific Rim</region>
      <region>United States</region>
   </exports>
</producer> 

The user will enter a value into an html form, which will search the XML document for that keyword, then print out the entire producer. So for example if the user searches for the product Salmon, the search will spit out the entire producer above. How do I go about detecting where I am in the XML document, then echoing out the entire producer?

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-27T06:20:18+00:00Added an answer on May 27, 2026 at 6:20 am

    I am assuming your producer elements are direct children of producers root node. If not, adjust accordingly:

    /producers/producer[descendant::*[contains(text(), "Salmon")]]
    

    This will find all producer elements that have the text Salmon in any of it’s child text nodes. This XPath allows you to search all the childnodes, e.g. region, town, product, etc – regardless of level.

    See Implementing condition in XPath for boilerplate code.

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

Sidebar

Related Questions

I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>
I have XML file which is looks like: <Report> <Total> <RecordValues> <Record> <FieldValue fieldName=index
i have an online xml file filled with items. At startup i check my
I have an XML file that reads like this <abc> <ab>value</ab> <aa>time</aa> <ac>money</ac> </abc>
I have an XML file that I'm trying to read from here , and
I Have following in my struts.xml file <action name=ProductVerification class=com.frontend.ProductVerification> <result name=success>/jsp/product_verification.jsp</result> <result name=input>/jsp/product_verification.jsp</result>
Good day, friends. I have a PreferenceActivity, it is filled from XML file. When
I have XML file template as : <Students> <Student> <StudentID></StudentID> <Name></Name> <Address></Address> <EmailId></EmailId> <StudentMobile></StudentMobile>
I have xml file that defines some preference screens like the following example <PreferenceScreen
I have xml file with such structure: ... <outer> ... <inner/> ... </outer> ...

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.