Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to change xml attribute values with dom, or sax or jaxp?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ranchers,

I am having an xml file as shown below



I want to change the value of param tags attribute value to "WARN" with name="Threshold".

Please provide me the code to do this using dom, or sax, or jaxp apis.

Thanks & Regards,
UmaSa
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems like you are trying to change the log4j configuration at runtime , its not advisable.

Anyways if you want to change XML using program , then you might want to read the xml onto a DOM object and then changes the required attribute and then again serialize it to XML.
 
umasankar puranam
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Rahul Bhattacharjee,

Do you mean we should not change the log levels dynamically or the approach that I am thinking is not currect. If my approach is not currect please suggest me a way to CHANGE THE LOG LEVELS DYNAMICALLY.

Thanks & Regards,
UmaSankar.P
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its not advisable to changes log level dynamically.
But you can try that out as mentioned in my first post.

You might have to use configure method again after changing the log4j configuration file so that the log4j system takes the changes.
 
umasankar puranam
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Rahul Bhattacharjee,

Please provide the sample code snippets to change the log levels dynamically.

Thanks & Regards,
UmaSankar.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic