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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:30:29+00:00 2026-05-11T13:30:29+00:00

I am trying to access an XMLList item and convert it to am XML

  • 0

I am trying to access an XMLList item and convert it to am XML object.

I am using this expression:

masonicXML.item.(@style_number == styleNum) 

For example if there is a match everything works fine but if there is not a match then I get an error when I try cast it as XML saying that it has to be well formed. So I need to make sure that the expression gets a match before I cast it as XML. I tried setting it to an XMLList variable and checking if it as a text() propertie like this:

var defaultItem:XMLList = DataModel.instance.masonicXML.item.(@style_number == styleNum);                     if(defaultItem.text())                     {                         DataModel.instance.selectedItem = XML(defaultItem);                     } 

But it still give me an error if theres no match. It works fine if there is a match.

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. 2026-05-11T13:30:30+00:00Added an answer on May 11, 2026 at 1:30 pm

    In my experience, the simplest way to check for results is to grab the 0th element of the list and see if it’s null.

    Here is your code sample with a few tweaks. Notice that I’ve changed the type of defaultItem from XMLList to XML, and I’m assigning it to the 0th element of the list.

    var defaultItem:XML =      DataModel.instance.masonicXML.item.(@style_number == styleNum)[0]; if( defaultItem != null )  {     DataModel.instance.selectedItem = defaultItem; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access a file for xml parsing with this: InputStream inputStream
After trying to access ivars using KVC, I have noticed that there was no
Hi I'm trying to access a WCF service which returns a JSON Array using
I am trying to access a file via a URI using the FTP protocol.
I have been trying to access/parse the message object found in the JSON results
I am trying to access an element in jquery using a function input. To
I'm trying to access a web service with JAX-WS using: Dispatch<Source> sourceDispatch = null;
Im trying to access the example/web folder (see below in the image) in a
When trying to access data-onload using $(#index).data(onload) I get back 'undefined' : <script type=text/html>
I'm trying to access the values of an object from a function I created

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.