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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:48:04+00:00 2026-06-02T12:48:04+00:00

My objective is to read an XML file and provide a simple interface that

  • 0

My objective is to read an XML file and provide a simple interface that will enable a (non-technical) user to modify this file. The xml file drives a Flash photo gallery and is pre-defined by that Flash Actionscript.

A sample of the XML is

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<photostack3d>
    <photos>
        <photo>
            <thumb src="Thumbs/bed1.jpg"/>
            <img src="Photos/bed1.jpg"/>
            <caption text="Master Bedroom"/>
            <desc><![CDATA[<h1>Master Bedroom</h1><br>The master bedroom is roomy and has a beautiful view of the landscaped back yard.]]></desc>
        </photo>
    </photos>
</photostack3d>

In this XML, there can be multiple photo nodes, since those define each of the photos that will be displayed by the gallery…

Now, I’m at the point where I am using DOM to create the file, so we’re good there. Using DOM to try and read it in for further editing is where I’m running into a problem. I can get to all of the photo elements, but I’m having a problem getting at the attributes in there, namely thumb, img, caption and desc. Currently, I have the following:

private void loadXML(String filePath)
{
    try 
    {
        File fXmlFile = new File(filePath);
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(fXmlFile);
        doc.getDocumentElement().normalize();

        System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
        NodeList photosList = doc.getElementsByTagName("photos");
        System.out.println("-----------------------");

        NodeList photoList = doc.getElementsByTagName("photo");
        System.out.println("Number of photo nodes: " + photoList.getLength());

        for (int temp = 0; temp < photoList.getLength(); temp++) 
        {

            NodeList thumbList = doc.getElementsByTagName("thumb");
            Element thumbElement = (Element) thumbList.item(0);

            String thumbName = thumbElement.getAttribute("thumb");
            System.out.println("thumb name: " + thumbName);

            //Node nNode = photoList.item(temp);
            //if (nNode.getNodeType() == Node.ELEMENT_NODE) 
            //{

            //  Element eElement = (Element) nNode;

            //  System.out.println("Source Name : " + eElement.getAttribute("text"));     //.getElementsByTagName("thumb"));
                //System.out.println("Source Name : " + getTagValue("thumb", eElement));
                System.out.println("-----------------------");
            //}
        }
    } 
    catch (Exception e) 
    {
        e.printStackTrace();
}

}

As you can see, I’ve been trying various different way to get at those attributes, but as of yet, just don’t see the values coming back. Where am I going wrong?

  • 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-02T12:48:06+00:00Added an answer on June 2, 2026 at 12:48 pm

    Have you tried thumbElement.getAttribute("src"); ?

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

Sidebar

Related Questions

So the objective of this is to read in a text file that contains
My objective is to read an XML text file and split each word and
Example: I read data from an XML file. This data has unique id elements.
I read in Cocoa and Objective C: Up and Running that -copy will always
I'm new to Objective-C and Cocoa. I've read that NSInteger and NSNumber are preferred
Objective: My script will download a remote file upon form submission, since the file
I have several XML files that I wish to read attributes from. My main
The Objective To read the csv file, and separate each line into an array.
I'm trying to write a validation script that will validate XML against the NITF
I just read this Use C Struct in Objective C question, and I was

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.