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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:07:13+00:00 2026-05-31T13:07:13+00:00

So I have the following XML file where I’m only interested in the <respcondition>

  • 0

So I have the following XML file where I’m only interested in the <respcondition> elements where there is only the <or> element in and not the <and> element.

I tried in PHP the following statement:

<!-- language: lang-php -->
foreach ($item->resprocessing->children() as $child) {
  if ((string) $child->getName() == 'respcondition') {
    if ((string) $child->respcondition->children()->getName() == 'conditionvar') {
      if ((string) $child->respcondition->conditionvar->children()->getName() == 'or') {
        $responseID = $child->respcondition->conditionvar->or->varequal->attributes()->respident;
        //some code
      }
    }
  }
}

}

But I only come in the first IF, so I figured out that children() doesn’t contain the entire XML from that element. Are there some alternatives I can use?

<!-- language: lang-xml -->
<resprocessing>
  <outcomes>
    <decvar varname="SCORE" vartype="Decimal" defaultval="0" minvalue="0.0" maxvalue="1.0" cutvalue="1.0"/>
  </outcomes>
  <respcondition continue="Yes" title="Mastery">
    <conditionvar>
      <or>
        <varequal respident="1000006631" case="Yes"><![CDATA[Mars]]></varequal>
      </or>
    </conditionvar>
    <setvar varname="SCORE" action="Add">1.0</setvar>
  </respcondition>
  <respcondition continue="Yes" title="Mastery">
    <conditionvar>
      <or>
        <varequal respident="1000006678" case="Yes"><![CDATA[Jupiter]]></varequal>
      </or>
    </conditionvar>
    <setvar varname="SCORE" action="Add">1.0</setvar>
  </respcondition>  
  <respcondition title="Mastery" continue="Yes">
    <conditionvar>
      <and>
        <or>
          <varequal respident="1000006421" case="Yes"><![CDATA[planets]]></varequal>
        </or>
        <or>
          <varequal respident="1000006468" case="Yes"><![CDATA[sun]]></varequal>
        </or>
        <or>
          <varequal respident="1000006558" case="Yes"><![CDATA[Mercury]]></varequal>
        </or>
      </and>
    </conditionvar>
    <displayfeedback feedbacktype="Response" linkrefid="Mastery"/>
  </respcondition>
</resprocessing>

Kind regards

  • 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-31T13:07:14+00:00Added an answer on May 31, 2026 at 1:07 pm

    Have a look at extracting it via xpath;

    The following will return you all the respcondition nodes, having a conditionvar node, with only “or” childnodes in it. In your xml example, this will not return anything, which i believe you’re aiming at.

    $xmlDoc->xpath('/resprocessing/respcondition[conditionvar/or]');
    

    Or, if you would like to extract the respcondition nodes, but now baring the “and” childnode in mind, use;

    $xmlDoc->xpath('/resprocessing/respcondition[conditionvar/and/or]');
    

    xpath is an easy and powerful way of navigating and extracting xml document, use it if possible.

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

Sidebar

Related Questions

I have the following XML file loaded into php simplexml. <adf> <prospect> <customer> <name
I have following xml file: <ab> <![CDATA[ <table> <tbody> <tr> <th>abcdef</th> </tr> <tr> <p>
I have the following XML File: <persons> <person name=shawn> <age>34</age> <hair style=spikes>red</hair> </person> <person
I have the following XML file:- <?xml version=1.0 encoding=UTF-8?> <viewentries> <viewentry position=1> <entrydata columnnumber=0>
I have the following xml file: <xfa:data> <form1> <Page1> <Page2> <contractInfo> ... </contractInfo> <paymentInfo>
I have the following XML layout file, HELPME.XML <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have the following invalid XML file: <?xml version=1.0 encoding=utf-8 ?> <Page num=1 crop_box=0,
I have the following in an XML file: <entry> ... <link href=http://www.example.com/somelink /> ...
I have the following text in xml file: <Config Builder=LP Wizard> <Libraries> <Library Name=XCAMSource/>
I have the following code in a drawable bitmap xml file. And the background

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.