Again and Again. Set Value to node of XML document

I've read many topics about how to set value in XML, but nothing works. Please, help
My xml file:
<TempEditData>
     <parameter userId="testUserId">
          <connectUrl>http://cognoslink</connectUrl>
          <connectUser>cognosTestUser</connectUser>
          <connectPwd>cognosPassword</connectPwd>
          <connectNamespace>cognosNamespace</connectNamespace>
          <reportStorePath>reportStorePath</reportStorePath>
          <reportUrlPath>reportUrlPath</reportUrlPath>
          <reportLifeLength>reportLifeLength</reportLifeLength>
     </parameter>
</TempEditData>My code:
private static void storeChartDataBeanParameters( String inputUserId) throws Exception{
          boolean isUserIdInFile = false;
          //create object
          DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        Document doc = docBuilder.parse (new File("src/tempCognosEditData.xml"));
        //normalize
        doc.getDocumentElement().normalize ();
        //get all Nodes
        NodeList listOfParameters = doc.getElementsByTagName("parameter");
        for(int i=0; i< listOfParameters.getLength(); i++){
             Node firstParameterNode = listOfParameters.item(i);
             //if first element is NODE
            if(firstParameterNode.getNodeType() == Node.ELEMENT_NODE){
                Element firstParameterElement = (Element)firstParameterNode;
                String userId = firstParameterElement.getAttribute("userId");
                //if !inputUserId
                if(!inputUserId.equals(userId)){
                     continue;
                //if userId was found in file
                else{
                     isUserIdInFile = true;
                     System.out.println("((Element)firstParameterElement).getElementsByTagName('connectUrl').item(0).getNodeName = " + ((Element)firstParameterElement).getElementsByTagName("connectUrl").item(0).getNodeName());
                     System.out.println("((Element)firstParameterElement).getElementsByTagName('connectUrl').item(0).getNodeValue = " + ((Element)firstParameterElement).getElementsByTagName("connectUrl").item(0).getNodeValue());
                     ((Element)firstParameterElement).getElementsByTagName("connectUrl").item(0).appendChild(doc.createTextNode("dzfgsdfgsdgf"));
                     /*NodeList insideList = firstParameterElement.getElementsByTagName("connectUrl");
                     Element element = (Element)insideList.item(0);
                     System.out.println ( "element.getNodeName() = " + element.getNodeName() );
                     element.setNodeValue("new TT");
                     System.out.println ("element.getNodeValue() = " + element.getNodeValue() );
                     //element.appendChild(doc.createTextNode("rrr"));
                     NodeList nl = element.getChildNodes();
                     System.out.println ("nl.item(0).getFirstChild().getNodeValue() = " + nl.item(0).getFirstChild().getNodeValue());
                     nl.item(0).getFirstChild().appendChild(doc.createTextNode("rrr"));*/
                                break;
            }//if ELEMENT_NODE
        }//for go through all nodes
     }Edited by: Holod on 03.03.2008 8:58

So, the solution is pretty easy:
storeChartDataBeanParameters( String inputUserId) searches for nodes named "+parameter+" in xml file with attribute "+userDd+".
If method parameter equals to xml data, I perform some operations and save new data.
The only thing, that saveFile(Document doc) must be syncronized.
Two users can't write to fie at the same time.
[This link|http://www.aviransplace.com/2005/03/20/working-with-xml-files-in-java-using-dom/5/] helped me alot.
Also Dr. Clap posts in different topics brought evidence to my mind.
private static void storeChartDataBeanParameters( String inputUserId) throws Exception{
          //create object
          boolean isUserIdWasFound = false;
          DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        Document doc = docBuilder.parse (new File("src/tempCognosEditData.xml"));
        //normalize
        doc.getDocumentElement().normalize ();
        //get all Nodes
        NodeList listOfParameters = doc.getElementsByTagName("parameter");
        for(int i=0; i< listOfParameters.getLength(); i++){
             Node firstParameterNode = listOfParameters.item(i);
             //if first element is NODE
            if(firstParameterNode.getNodeType() == Node.ELEMENT_NODE){
                Element firstParameterElement = (Element)firstParameterNode;
                String userId = firstParameterElement.getAttribute("userId");
                //if !inputUserId
                if(!inputUserId.equals(userId)){
                     continue;
                //if userId was found in file
                else{
                     isUserIdWasFound = true;
                     NodeList parameterNode = firstParameterElement.getElementsByTagName("connectUrl");
                     Element connectUrlElement = (Element)parameterNode.item(0);
                     System.out.println("connectUrlElement name = " + connectUrlElement.getNodeName());
                     System.out.println("connectUrlElement value = " + connectUrlElement.getNodeValue());
                     System.out.println("((Node)connectUrlElement) value = "+((Node)connectUrlElement).getNodeValue());
                     ((Node)connectUrlElement.getFirstChild()).setNodeValue("normalized");
                     saveFile(doc);
                     break;
            }//if ELEMENT_NODE
        }//for go through all nodes
     public static void main(String[] args) throws Exception{
          storeChartDataBeanParameters("testUserId");
     public static void saveFile(Document doc) throws Exception{
          Transformer transformer;
          transformer = TransformerFactory.newInstance().newTransformer();
          transformer.transform(new DOMSource(doc), new StreamResult(new File("src/tempCognosEditData.xml")));
     }Edited by: Holod on 03.03.2008 15:52

Similar Messages

  • Problem with internet. When i open System preferences, Network, message drops down: 'your network settings have been changed by another application'. I click OK, but it drops a message again and again, preventing me to do anything about the setting.

    Problem with internet. When i open System preferences, Network, message drops down: 'your network settings have been changed by another application'. I click OK, but it dropps the message again and again, preventing me to do anything about the setting.

    A Fix for "Your network preferences have been changed by another application" Error 
    In the Library/Preferences/SystemConfiguration/ folder delete the following:
    com.apple.airport.preferences.plist
    NetworkInterfaces.plist
    preferences.plist
    com.apple.nat.plist
    You will have to re-configure all your network settings since deleting.
    (10.4.10)
    Use Software Update to update your OS to last version of Tiger.  Install all the other updates that goes along w/it.

  • I can`t use apple store. my apple id needs my paswoord, to set the security questions, after I introduce the paswoord it askes for the paswoord again and again! it doesn`t work, and the paswoord is the right one. What can i do?

    i can`t use apple store. my apple id needs my paswoord, to set the security questions, after I introduce the paswoord it askes for the paswoord again and again! it doesn`t work, and the paswoord is the right one. What can i do?

    I have figured out already. Firstly please try:
    1) Installing iBooks on your iPhone via iTunes on PC/MAC
    2) Adjust the time of your iPhone to 6 months ahead (e.g. 2013 May)
    3) Close all apps currently running, clear Safari cache and history, sign out of Apple ID (Settings>iTunes & App Stores), reboot your device
    4) Open iBooks on your iPhone, download any 1 book
    5) System should prompt you to enter 3 security questions
    6) Enter your answer and click "Done" at bottom right part of your input keyboard (Do not press upper right button)
    7) Done!
    I cannot imagine the system has gone so stupid. Apple, please retify the problem ASAP.

  • HT2729 Sometimes when I am watching videos on my ipad2, it pauses and I have to push play again and again to continue. Do I have an incorrect setting?

    Sometimes when I am watching videos on my Ipad2, it pauses and I have to continuously play again and again. Is there a problem with one of my settings?

    It has always been very basic to always maintain a backup copy of your computer.
    Have you failed to do this?
    If so, not good, you can transfer itunes purchases from the iphone to your computer.  File>Devices>Transfer Purchases
    You can also redownload some itunes purchases in some countries:
    Download past purchases - Apple Support

  • Firefox asking ID and Password again and again

    Hi,
    I don't know what happened yesterday that Firefox is asking for id and password again and again whenever i open central admin or any other share point site.Internet Explorer and Google Chrome are working normally but Firefox is not able to open a site and
    keep asking for the credentials.
    I entered the same credentials which i am using on other browsers such as IE or Chrome in the format Domain\User Name.
    I didn't update any thing on my machine which might have caused this issue.
    Urgent help require.

    Hi,
    As this issue is only related to Firefox, maybe you had made some settings for the Firefox.
    You can enable the auto login or remember the password.
    Open "about:config" in Firefox
    Accept and Continue
    Search for "autologin"
    Double click on the "signon.autologin.proxy" to toggle it's value ( set to true )
    Firefox will cache the username and password and as long as the cached ones are correct, it won't ask you for username or password.
    What’s more, you can reset the Firefox to check whether it works.
    Help-> Troubleshooting Information->Reset Firefox
    If the issue still occurs, you can post your question to the forum for Firefox:
    https://support.mozilla.org/en-US/questions
    More experts will assist you, then you will get more information relation to Firefox.
    Thank you for your understanding and support.
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • After updating office365's password, can't login outlook, always let you input password again and again

    Dear all,
           This is a real issue in working. User uses win7 and Outlook2007.
    The issue is that after updating office365's password, users can't login outlook, always let you input password again and again. Sometimes, we can fix the issue by deleting current outlook profile then create a new one. But sometimes the method can't work.
    What is the root reason?
    Many thanks,
    Franklin hong

    Hi Franklin,
    Firstly, please make sure you can access the mailbox with the new Password in OWA. Then check your Account settings in Outlook 2007:
    Click Tools > Account Settings. In the E-mail tab, double click the Exchange account. Click More Settings > Security > Select Negotiate Authentication > OK.
    Please try to clean up the cached credential in your computer. Then fill in with the format of UPN when it prompted for credentials next time and check the Remember my credential to save it. About how to remove cached credentials, please follow these steps:
    1. Launch the Credential Manager from Control Panel > All Control Panel Items > Credential Manager.
    2. In the Generic Credentials section you’ll see a setting for [MS Outlook] which will include your SSO details. Click the downward-pointing arrow to the right of that value.
    3. In the expand details, click Remove from vault. Then Outlook will no longer have a stored copy of your password.
    Thanks,
    Winnie Liang
    TechNet Community Support

  • My new ipod touch 4g doesn't let me download apps, it just says type in Apple ID password and when i do it asks for it again and again and again....

    My new ipod touch 4g doesn't let me download apps, it just says type in Apple ID password and when i do it asks for it again and again and again.... what should i do?

    I've got the same problem as well. When i connect all i see is "set up your iphone" screen. It worked perfectly fine a couple of weeks back when I last synced but, doesn't sycn anymore.
    Any help would be appreciated.

  • Can we open and close the cursor again and again

    hi all,
    with the help of cursor select statement i am writing some columns into the text file. while writing into the file in between i want to write something which belongs to others cursor. shall i close the first cursor and reopen it again..
    is its works?

    If you are using for loop the you don't need to open and close the cursor like:
    SQL> set autot off
    SQL> begin
      2     for i in (select ename, deptno, sal from emp)
      3     loop
      4             for j in (select dname from dept where deptno = i.deptno)
      5             loop
      6             dbms_output.put_line ('Ename:' || i.Ename ||'  Dept Name:'|| j.dname);
      7             end loop;
      8     end loop;
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on
    SQL> /
    Ename:SCOTT  Dept Name:RESEARCH
    Ename:first_0  Dept Name:SALES
    Ename:first_1  Dept Name:SALES
    Ename:first_0  Dept Name:RESEARCH
    Ename:first_1  Dept Name:SALES
    Ename:first_0  Dept Name:SALES
    Ename:first_1  Dept Name:ACCOUNTING
    Ename:first_0  Dept Name:RESEARCH
    Ename:first_1  Dept Name:ACCOUNTING
    Ename:first_0  Dept Name:SALES
    Ename:first_1  Dept Name:RESEARCH
    Ename:first_0  Dept Name:SALES
    Ename:first_1  Dept Name:RESEARCH
    Ename:first_0  Dept Name:ACCOUNTING
    PL/SQL procedure successfully completed.
    SQL> Or let us know about your requirements i.e. why you need to open/close the cursor again and again.

  • TS1702 how do you stop itunes from downloading apps over and over again and again like for ever it wont stop  help.

    how do you stop itunes from downloading apps over and over again and again like for ever it wont stop  help.
    i tryed everything i  can in the setting and so on , i even clicked on the downloads arrow to pause it and delete them but like i said it will now stop.
    theres apps i just dont want. theres a list of them but theres not a place were i can get rid of them. it also says some stuff about icloud yeah right like i have ios 5 or 7 ha . pod touch 2 is what i have lol . plz help thanks.

    to the right by search library theres an arrow there click on it : it will show you what it is downloading , from there you can pause and select all and delete them but still will continue to download them if you tell itunes to check for downloads. that download engien is crazy i tell yeah.
    no matter what we do it will still download them trust me i tryed everything and i also went to icloud to see if it was there but to what i see is that there is no apps there this is some crazy itune program that needs to remade.

  • How can I DISABLE the pop up 'Would you like to copy it to Library', preventing this message from bothering for each and every book, again and again, time after time? (Windows 7 64bit US).

    How can I DISABLE the pop up 'Would you like to copy it to Library', preventing this message from bothering for each and every book, again and again , time after time? (Windows 7 64bit US).
    I guess this may be a feature request. Adobe may think this is a good message for every new eBook.
    I sure would like to decide about that myself.
    Thanks in advance if this will be changed.

    singmk wrote:
    Decided to setup the mail for exchange on my N8 so I could see my work emails. Worked like a charm but after a couple of hours decided I didn't like being that contactable so deleted the mailbox.
    Now to the problem, during setup I was forced to enable the phone lock and had to pick a 7 digit alphanumeric code. Fair enough I thought and went ahead. When I removed the mailbox however the lock remained in place with the default auto time of 30 minutes. When I checked in Phone management there is no option to disable this lock so I thought I could at least change the default time to something bigger but when you try, it remains at 30 mins. You also can't disable the auto time as it pops up an error message saying can't unlock phone.
    Does anyone know if I'm missing something obvious here or is this something which can't be disabled once it's switched on? I've done a soft reset back to factory settings with no luck and the only other thing I can think of is re installing the firmware which seems a bit extreme.
    Would like to hope there is some way to have control over this. Can someone help?
    Which firmware your N8 having now? You can check firmware by choosing Call, then type *#0000#.
    My N8 works fine on security setting and able to define Phone auto lock period, by choosing Menu>Settings>Phone>Phone management>Security settings>Phone and SIM card>Phone auto lock period>User defined>Lock after(minutes)
    You will prompt to enter Lock code each time u define auto lock priod or enable/disable auto lock.
    Hope this can help you.
    If you find this post helpful, please show your appreciation by clicking the Kudos star at the left. If it provides you the solution, please click on the GREEN Accept as Solution button at below

  • Dont want to put pasword again and again

    how i will turn off key pad lock password
    in menu-options -security options-general setting-pasword is enabled
    i dont want to put pasword again and again i want to disable it
    please help me friends

    EMOTION wrote:
    in menu-options -security options-general setting-pasword is enabled
    Set that (in red above) to DISABLED, and save.
    If you have a red lock symbol next to that setting you cannot. If that is the situation, you are probably in a corporate BES which REQUIRES you to use a password via the IT Policy set to the device by your employer.
    Is that your situation?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • HT204088 I already purchasing game item yesterday. It was written unable to purchase. I though my transaction was failed so i tried again and again but it still unable. And now my credit cards over limit. What happened here?

    I dont know what happened, i get charged from my father visa credit card. I play Ragnarok Valkyrie Uprising game which can buy shop item(name ruby). First time i tried to purchasing 210 rubies it cost 189 In Rupiah(Indonesian currency) but it was failed and showing dialog box unable to purchase ruby. So I tried again and again bought rubies with different values (10 rubies,50 rubies,210 rubies) but that unable to purchase dialog box always appears.  I though the purchasing rubies transaction was failed. Then i was trying to find whats wrong and get some information from the internet all day until i calling my credit card (Citibank/visa) technical support, he said i was already did some transaction for this. i ever did rubies transaction before and it was completely working. Please help. wheres my money gone? wheres my 210 rubies? I even cant check my billing information and purchased history cause my credit card is declined by itunes cause over limit. Pls give me respon to solve this.

    Hello Ading,
    It sounds like you were charged for an in App purchase but did not receive the item. I would report this issue to iTunes Store support with the following article:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/ht1933
    To report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase, follow these steps:
    Find the email receipt for your purchase.
    Click Report a Problem under the app that is having the issue.
    When prompted, enter the Apple ID and password you used to purchase the item, then click Report a Problem.
    Click Report a Problem next to the item you are having an issue with.
    From the Choose Problem dropdown menu, choose the appropriate issue.
    Follow the onscreen instructions and—if prompted—type a description of the problem into the text field.
    Click Submit to have your issue reviewed.
    Thank you for using Apple Support Communities.
    Regards,
    Sterling

  • I cannot retrieve my emails on my Mac Book Pro operating on 10.7.3 Icloud was already workingit keeps asking for password and when i put correct password in it keeps asking for it again and again. This has just started today

    I cannot retrieve my emails on my Mac Book Pro operating on 10.7.3 Icloud was already workingit keeps asking for password and when i put correct password in it keeps asking for it again and again. This has just started today

    Though it's unlikely to be wrong if things were set up properly in the first place, as a check go to Mail Preferences>Accounts and check that the server setting for IMAP (incoming) is imap.mail.me.com (not just mail.me.com).
    Your next step either way would be to go to System Preferences>iCloud and sign out, then sign back in again. (You can ignore warnings about data disappearing - your calendars etc. will disappear when you sign out but reappear when you sign back in).

  • HELP!!! When I sign into FaceTime or imessage, when I sign in it makes me sign in again and again until it says that the password is incorrect!!!! I know it correct!!! Please help I can't sign in!!

    HELP!!! When I was using imessage on my phone it worked perfectly, but on my ipad, when I sign in it makes me write my password again and again until it says my password is incorrect!! Please help, I know my password is corrcect and I don't know what's going on with imessage.

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    iOS: FaceTime is 'Unable to verify email because it is in use'
    http://support.apple.com/kb/TS3510
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538
    How to Set Up & Use iMessage on iPhone, iPad, & iPod touch with iOS
    http://osxdaily.com/2011/10/18/set-up-imessage-on-iphone-ipad-ipod-touch-with-io s-5/
    Extra FaceTime IDs
    http://tinyurl.com/k683gr4
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Troubleshooting iMessage Issues: Some Useful Tips You Should Try
    http://www.igeeksblog.com/troubleshooting-imessage-issues/
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    Fix Can’t Sign Into FaceTime or iMessage iOS 7
    http://ipadtutr.com/fix-login-facetime-imessage-ios-7/
    FaceTime, Game Center, Messages: Troubleshooting sign in issues
    http://support.apple.com/kb/TS3970
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
    How to Block Someone on FaceTime
    http://www.ehow.com/how_10033185_block-someone-facetime.html
    My Facetime Doesn't Ring
    https://discussions.apple.com/message/19087457
    Send an iMessage as a Text Message Instead with a Quick Tap & Hold
    http://osxdaily.com/2012/11/18/send-imessage-as-text-message/
    To send messages to non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
    How to Send SMS from iPad
    http://www.iskysoft.com/apple-ipad/send-sms-from-ipad.html
    You can check the status of the FaceTime/iMessage servers at this link.
    http://www.apple.com/support/systemstatus/
     Cheers, Tom

  • Dreamviewer CS5 opens but shuts down right after first view again and again...without no error information

    I have Adobe Premium CS5 for MAC. My Dreamviewer CS5 opens but shuts down right after first view again and again. With no error information.
    I have tried to download it again (web download link) with reopening the computer, but still it does not work.
    Did not ask any serial numbers at all so I assume I was able to "smell" existing program on computer.
    As Dreamviewer is part of bigger package, do i have to install only this program, web design set or what?
    Do I have to download some other programs to get it work? All other graphic and web programs open and work properly.
    What to do? Will it install it again if not uninstalled first?

    For something like this, I would try clearing the program cache first: Deleting a corrupted cache file
    Then restore preferences if the cache trick didn't work: Restore preferences | Dreamweaver CS4, CS5, CS5.5, CS6
    And finally, if neither work, reinstalling using the cleaner tool instructions here: Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6

Maybe you are looking for