JAXP DOM - I can get children fine, just not nested children!
Hi,
I have a problem with JAXP dom. I cannot get the nested children associated.
Here is my code:
try {
DOMParser parser = new DOMParser();
String url = "file:/myxml.xml";
parser.parse(url);
Document doc = parser.getDocument();
//Get the filename
NodeList FileNameNodeList = doc.getElementsByTagName("filename");
//Get the duration
NodeList DurationNodeList = doc.getElementsByTagName("duration");
//Get the headline
NodeList HeadLineNodeList = doc.getElementsByTagName("headline");
//Get the description
NodeList DescriptionNodeList = doc.getElementsByTagName("description");
//Get the keywords
NodeList KeyWordsNodeList = doc.getElementsByTagName("keywords");
//Get the link order
//Read all values for every "File Name"
for(int i=0; i<FileNameNodeList.getLength(); i++){
//Get the values
Node FileNameNode = FileNameNodeList.item(i);
Node DurationNode = DurationNodeList.item(i);
Node HeadLineNode = HeadLineNodeList.item(i);
Node DescriptionNode = DescriptionNodeList.item(i);
Node KeyWordsNode = KeyWordsNodeList.item(i);
//File name
if(FileNameNode.getFirstChild() != null){
Message += "<br><b>Filename:</b> " + FileNameNode.getFirstChild().getNodeValue();
//Duration
if(DurationNode.getFirstChild() != null){
Message += "<b>Duration:</b> " + DurationNode.getFirstChild().getNodeValue();
//Head line
if(HeadLineNode.getFirstChild() != null){
Message += "<b>Head Line:</b> " + HeadLineNode.getFirstChild().getNodeValue();
//Description
if(DescriptionNode.getFirstChild() != null){
Message += "<b>Description:</b> " + DescriptionNode.getFirstChild().getNodeValue();
//Key words
if(KeyWordsNode.getFirstChild() != null){
Message += "<b>Key Words:</b> " + KeyWordsNode.getFirstChild().getNodeValue();
//Build the string
String MessageTemp = Message;
Message = "<font size=-1>" + MessageTemp + "</font>";
return Message;
} catch (Exception ex) {
System.out.println(ex);
return Message + ex.toString();
Here is part of my XML File:
- <article storyorder="1" pubdate="11/6/02 3:28:27 AM" source="MSNBC Video" topnews="1">
<filename>vh</filename>
<duration>00:01:58</duration>
<headline>MSNBC’s Video Headlines</headline>
<description>The latest news from MSNBC.com</description>
<keywords>headlines, news headlines</keywords>
<photographer />
<aspect>4:3</aspect>
- <linkinfo>
- <link order="1">
<linkurl>http://www.msnbc.com/news/828323.asp</linkurl>
<linktext>Republicans win control of Congress</linktext>
</link>
- <link order="2">
<linkurl>http://www.msnbc.com/news/828325.asp</linkurl>
<linktext>Republicans widen House majority</linktext>
</link>
- <link order="3">
<linkurl>http://www.msnbc.com/news/828326.asp</linkurl>
<linktext>Democrats retake some statehouses</linktext>
</link>
</linkinfo>
- <categories>
- <category id="News">
- <topics>
<topic>International</topic>
<topic>US</topic>
</topics>
</category>
</categories>
</article>
I can get filename, duration, etc. But I cannot get the multiple link URLs associated with the filename. How can I get that?
Thanks
Call getDocumentElement() on the document to obtain the root node. Then call getChildNodes() on the root node to get its children, each individual child can be accessed by looping, as follows :
// Get the Document object.
Node node = document.getDocumentElement();
NodeList childNodes = node.getChildNodes();
for(int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
// Perform some action on the node, or get its children to burrow
// further down the DOM tree.
}If you know how many levels you need to go down then you'll need that many nested for loops but recursion is a far more elegant solution.
Similar Messages
-
Only a portion of my contacts import into iCloud. Contact list was created in Outlook and imports to iPhone fine - just not to iCloud. All info is also not transferred to contact which do copy. What can I do?
You cannot merge AppleIDs
-
My Macbook (2009 White) Has had water spilled onto it, it all works apart from the screen. When connected to an external display it works fine, just not on the Macbook itself. Does anyone know how to fix this?
Take it to Apple and ask them to fix the physical damage the water caused.
Allan -
Hi there. I have the ipad 3, and just last night had to reboot and do the upgrade, now my texting and facetime on it is not working...it states that when I click to activate it, and put in my user id(email) and passcode....that" could not sign in...please chekc network connection and try again".....well my Wifi connection is fine, and i can text and facetime fine from my iphone..just not the ipad now.....any ideas why it will not take my user id and passcode?...the passcode works fine on my iphone.
Hello cohenj80,
Thank you for the details about the FaceTime and iMessage activation issue you are experiencing on your iPad 3. I recommend following the steps in this article when you are not able to sign into FaceTime or iMessage on your iPad:
iOS: Troubleshooting FaceTime and iMessage activation
http://support.apple.com/kb/ts4268
Best,
Sheila M. -
I can get to the website but when I am asked the security question I get a big white box in the middle of the screen. I have cleared history and cookies and cannot fix it.
Please read this whole message before doing anything.
This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
The purpose of this exercise is to determine whether the problem is localized to your user account, or is system-wide. Enable guest logins and log in as Guest. For instructions, launch the System Preferences application, select “Help” from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
While logged in as Guest, you won’t have access to any of your personal files or settings. Any application you run will behave as if you were running it for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
As Guest, launch the application(s) and test. Same problem(s)?
After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it. -
Can get list of OSS notes, but when click on them, cannot view them.
Wasn't sure where to post this and this looked like the most general place, so hopefully this works...
I have a SAP Service Marketplace id and need to view SAP notes. I can get to the note "Search" screen, but when I enter the note id and hit enter, I get an empty msExplorer popUp window. I also tried searching by application and received several pages of notes, but when I click on any one of them the same thing happens.
I had a colleague try this and he is able to view the note. Only difference is that he gets a second login popup window, but after filling it in he can view the note.
Possibly this is a permissions issue? If so, any idea whom to contact?
Any suggestions as to what I need to do to view notes would be greatly appreciated.
Thank you,
Dean Atteberry.I had a similar problem - was caused by the SAP cerificate (SAP Passport CA) installed on my PC which had reached its 12 month limit and expired.
Would get first popup for search screen for notes where I could enter my ID and password, but no second pop-up to open individual notes
When I went and downloaded a new certificate, it all started working OK
Andrew -
My computer crashed and lost everything. i have to re-install iTunes, is there a way i can sync my phone and not lose everything?
See these guides:
Syncing to a "New" Computer or replacing a "crashed" Hard Drive
Recovering your iTunes library from your iPod or iOS device -
I tried to respond to several of you that have posted about this but the site will not let me respond. I am also having issues with hotmail email since about 5:30pm today. I can not connect to the server and no emails will load on my phone but I have no issues getting them on my computer. My husband is having no issues, he uses AT7T and I
That is a hotmail issue, since you can't connect to their server contact Microsoft to resolve the issue
-
I"ve reset my password from my laptop thinking the password was the problem, but the imac mail just keeps asking for the password. It keeps saying The MobileMe IMAP server “mail.me.com” rejected the password for user. Am abit confused as maybe the mail on the imac should be icloud?
I really have no idea what's going on. Any help would be greatly appreciated!Welcome to the Apple Community.
Delete your mail account from Mail preferences and set it up again using the Mail Server Information.
Some users have apparently encountered issues using this information in pre-Lion set ups (I haven't), Roger Wilmut has kindly provided instructions for those who find themselves with this problem.
Entering iCloud email settings manually in Snow Leopard or Leopard -
I have the latest FF, W7. I've cleared cache, cookies, used FF in safe mode, etc.
ginajo, please also contact the developer of the site, however in the meantime, there is a way to forget the site from the cache entirely.
Or to bypass the cache:
Reload the webpage while bypassing the cache using '''one''' of the following steps:
*Hold down the ''Shift'' key and click the ''Reload'' button with a left click.
OR
*Press ''Ctrl'' + ''F5'' or ''Ctrl'' + ''Shift'' + ''R'' (Windows and Linux)
*Press ''Command'' + ''Shift'' + ''R'' (Mac)
However please take note that it would not be recoverable.
# Go to about:permissions in a new window
# search for the site
# click on "Forget this Site" -
I can play flash videos, just not the ones on AdobeTV
I'm running 64 bit Windows XP, service pack 3. I downloaded the Flash CS5 free trial, and decided to look at the getting started videos. I can watch any flash video I come across on any other site, but for some reason the videos at http://tv.adobe.com/show/learn-flash-professional-cs5/ will not load. I already thought to update my flash player, but I have the latest version and the video still does not play. It shows the buttons at the bottom of the video, and it shows the three dots in the middle of the screen like it's loading, but it just stays that way forever without actually loading!
My bad, I thought the picture would show in the forum. The menu says:
ATVplayer v.2.1.0320
Settings...
Global Settings...
About Adobe Flash Player 10... -
I can get into GMail but not my Calinder it is blocked by firefox ?
GMail runs fine ... but when i try to use my calender I get.
The page isn't redirecting properly. I don't know what to do ?
thanks Help if you can :)This can be often be fixed by clearing the Google cookies and the cache. For details on how to do that see [[deleting cookies]] and [[how to clear the cache]].
-
Help VOD says not subscribed but I am and get the channels just not the VOD
Spent several hours on phone, several resets, several unplugs. In Home Agent. Even transfered me to billing to make sure I was Ultimate TV (and I am) I don't get Epix, Sundance, and some other On Demand sections. Have even tried to subscribe via remote and it won't let me. (i figured if it worked I could then get billing to clear it up)
any ideas? I can't spend more time on the phone just to try the same steps. The last agent got off the phone with me telling me it might just need to take 24 hours for the reset to work. Pretty sure she was at a loss and just wanted me off phone.
any help would be appreciated Thank Youtry logging in at www.myverizon.com
after you login type in www.verizon.com/fiostvonline
if that doesn't work, then try the chat support by clickign on contact us at the bottom. -
I can not get or send mail from my iPhone, iCloud, and desktop mail. All are the same account, password is right and working. When the problem first happened I updated to a new password.
The Mail and the phone are telling me ( "The iCloud IMAP server “p99-imap.mail.me.com” rejected the password for user “k****n******2”}
From the iCloud account i get a message saying mail could not be loaded and the details. Which i have copyed below.
Any thoughts or anyone I can ring ? This was a paid for mobile me account.
Thanks
Running 10.72
ORIGIN
server
TYPE
error
BUILDNUMBER
1FCS29.34215
TIME
Sun Dec 11 2011 10:49:50 GMT+0000 (GMT) (1323600590380)
HOST
www.icloud.com
USERAGENT
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7
PRSID
217870346
RECENTLOGMESSAGES
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: MAIL in main()
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: --> Request 1: POST to https://p99-mailws.icloud.com:443/wm/preference, headers: Content-Type=text/plain, body: (omitted)
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: Request out: /wm/preference-list-->1323600562085/1
params: {"locale":"en-us","timeZone":"Europe/Dublin"}
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Object:sc1074:dispatch('load content')
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: "2.0 Waiting for Content" handled event 'load content' (no transition)
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Module: Attempting to load 'addresses'
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Module: Module 'addresses' is not loaded, loading now.
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Module: Loading JavaScript file in 'addresses' -> '/applications/mail/frameworks/addresses/en-us/1FCS29/javascript.js'
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Object:sc3099:initStatechart()
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: -> entering "9 Address List Not Visible"
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: --> Request 2: GET to https://p03-contactsws.icloud.com:443/co/addressbook/?order=first,last&locale=en _US, headers: Content-Type=text/plain, body: (omitted)
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Module: Module 'addresses' finished loading.
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Module: Evaluating and invoking callbacks for 'addresses'.
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: SC.Module: Module 'addresses' has completed loading, invoking callbacks.
Sun, 11 Dec 2011 10:49:22 GMT: DEBUG: APPLICATION: Received applicationWillBecomeActive
Sun, 11 Dec 2011 10:49:23 GMT: WARN: APPLICATION: Received applicationDidBecomeActive
Sun, 11 Dec 2011 10:49:23 GMT: DEBUG: <-- Response 2: 200 (1257ms), headers: Cache-Control=no-cache, no-store, private, Content-Type=application/json; charset=UTF-8 body: (omitted)
Sun, 11 Dec 2011 10:49:25 GMT: DEBUG: willReceive: Status:500, Request:/wm/preference
Sun, 11 Dec 2011 10:49:25 GMT: DEBUG: Got HTTP 500 : Redirecting request: /wm/preference : Redirect count:1
Sun, 11 Dec 2011 10:49:25 GMT: DEBUG: --> Request 3: POST to https://p99-mailws.icloud.com:443/wm/preference, headers: Content-Type=text/plain, body: (omitted)
Sun, 11 Dec 2011 10:49:25 GMT: DEBUG: Request out: /wm/preference-list-->1323600562085/1
params: {"locale":"en-us","timeZone":"Europe/Dublin"}
Sun, 11 Dec 2011 10:49:29 GMT: DEBUG: willReceive: Status:500, Request:/wm/preference
Sun, 11 Dec 2011 10:49:29 GMT: DEBUG: Got HTTP 500 : Redirecting request: /wm/preference : Redirect count:2
Sun, 11 Dec 2011 10:49:29 GMT: DEBUG: --> Request 4: POST to https://p99-mailws.icloud.com:443/wm/preference, headers: Content-Type=text/plain, body: (omitted)
Sun, 11 Dec 2011 10:49:29 GMT: DEBUG: Request out: /wm/preference-list-->1323600562085/1
params: {"locale":"en-us","timeZone":"Europe/Dublin"}
Sun, 11 Dec 2011 10:49:33 GMT: DEBUG: willReceive: Status:500, Request:/wm/preference
Sun, 11 Dec 2011 10:49:33 GMT: DEBUG: Got HTTP 500 : Redirecting request: /wm/preference : Redirect count:3
Sun, 11 Dec 2011 10:49:33 GMT: DEBUG: --> Request 5: POST to https://p99-mailws.icloud.com:443/wm/preference, headers: Content-Type=text/plain, body: (omitted)
Sun, 11 Dec 2011 10:49:33 GMT: DEBUG: Request out: /wm/preference-list-->1323600562085/1
params: {"locale":"en-us","timeZone":"Europe/Dublin"}
Sun, 11 Dec 2011 10:49:37 GMT: DEBUG: willReceive: Status:500, Request:/wm/preference
Sun, 11 Dec 2011 10:49:37 GMT: DEBUG: Got HTTP 500 : Redirecting request: /wm/preference : Redirect count:4
Sun, 11 Dec 2011 10:49:37 GMT: DEBUG: --> Request 6: POST to https://p99-mailws.icloud.com:443/wm/preference, headers: Content-Type=text/plain, body: (omitted)
Sun, 11 Dec 2011 10:49:37 GMT: DEBUG: Request out: /wm/preference-list-->1323600562085/1
params: {"locale":"en-us","timeZone":"Europe/Dublin"}
Sun, 11 Dec 2011 10:49:40 GMT: DEBUG: willReceive: Status:500, Request:/wm/preference
Sun, 11 Dec 2011 10:49:40 GMT: DEBUG: Got HTTP 500 : Redirecting request: /wm/preference : Redirect count:5
Sun, 11 Dec 2011 10:49:40 GMT: DEBUG: --> Request 7: POST to https://p99-mailws.icloud.com:443/wm/preference, headers: Content-Type=text/plain, body: (omitted)
Sun, 11 Dec 2011 10:49:40 GMT: DEBUG: Request out: /wm/preference-list-->1323600562085/1
params: {"locale":"en-us","timeZone":"Europe/Dublin"}
Sun, 11 Dec 2011 10:49:44 GMT: DEBUG: willReceive: Status:500, Request:/wm/preference
Sun, 11 Dec 2011 10:49:44 GMT: DEBUG: <-- Response 7: 500 (4248ms), headers: Content-Type=text/html body: (empty)
Sun, 11 Dec 2011 10:49:44 GMT: DEBUG: Request in: /wm/preference-list-->1323600562085/1,500,4249ms
Sun, 11 Dec 2011 10:49:44 GMT: DEBUG: ServerPreferencesDataSource.retrieveResponse error = -1/500/guid=serverPrefsGuid
Sun, 11 Dec 2011 10:49:44 GMT: ERROR: CoreMail handled error 13002 before exiting MailSpent at least 40 min talking to apple support, to sort it out. luckly not at my cost. After trying lots of things and speaking to a higher grade support person I was given a temp password which did the trick. I then was able to reset that with my own password.
The impression i got was no one knowns what the problem is and resetting the password at the apple end works. Not sure if you would be able to self fix. -
I can use Explorer to get to to the webmail, but Firefox no longer works.
You can not merge accounts.
Apps are tied to the Apple ID used to download them, you can not transfer them.
Maybe you are looking for
-
I am fairly new to doing web page updates through Dreamweaver. I currently switched from IE to Firefox. When I make changes on web pages and download them IE shows the changes but Firefox does not, on my computer. == This happened == Every time Firef
-
Can a subVI tell when the application it is part of has been stopped and restarted?
Can a subVI tell when the application it is part of has been stopped and restarted? It is easy enough for a subVI to tell when it has been run for the first time after having been loaded into memory. But is there a way for a subVI to tell when the ap
-
I'm getting this error, (err = 100000) Than its says, the file seems to be corrupted... If anyone could tell me whats going on that would be great, Thanks
-
How to pull payment terms attached to customer, Invoice, Agreement
Hi All, Could you please help me how to pull the payment terms attached to a particular Invoice, customer and agreement. Thanks for your help, Prathima
-
Import into Lookup Hierarchy Multi-Value Field
My source data contains two fields (Product ID, Product Notes). I need to map the Product Notes into a Hierarchy Lookup Field on main products table. THe hierarchy table for product notes contains two text fields and both are display fields. My sou