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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:43:09+00:00 2026-06-11T14:43:09+00:00

I’m working with sax in PHP because the xml file that I am parsing

  • 0

I’m working with sax in PHP because the xml file that I am parsing to update a database with is around 150MB.

I’m having trouble understanding how to tell where in an xml object I am using sax. for instance the xml looks something like this:

<listing>
    <home>
        <address>123 main st.</address>
    </home>
    <brokerage>
        <address>555 N. high st.</address>
    </brokerage>
</listing>

Using sax, I know when the listing tag starts, and the home tag, and then the address tag and such, but then control is passed to the function i set with xml_set_character_data_handler and i can get the address.

My problem is in knowing whether I’m reading home -> address or brokerage -> address.

There are multiple fields in this xml file that share the same tag name, and are used multiple times under different parent tags (firstName, lastName, phone, email, etc. as children under listingAgent, propertyContact, etc.).

I’ve been googling around, but the only sax examples I’m finding show how to echo the data, and not how to make decisions based on the data in the xml file. Is there a function that I’m not aware of, or do I have to write my own function to determine which parent elements a child belongs to?

  • 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-11T14:43:10+00:00Added an answer on June 11, 2026 at 2:43 pm

    You could check your position within XML document using simple stack, that stores a list of opened tags (pseudocode):

    $openedTags = array();
    
    while ($node = /* read next XML node*/) {
        if ($node->isOpeningTag()) {
            array_push($openedTags, $node->getTagName());
            continue;
        }
    
        if ($node->isClosingTag()) {
            array_pop($openedTags);
            continue;
        }
    
        if ($node->isTextNode()) {
            print_r($openedTags);       // root ... listing, home, address
            echo $node->getTextValue(); // 123 main st.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a reasonable size flat file database of text documents mostly saved in
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm trying to create an if statement in PHP that prevents a single post

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.