Re: Editing Attributes
Rolf Lear <[email protected]> Sun, 13 May 2012 08:37:48 -0400
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <[email protected]> |
You can simply change the value of the Address attribute.
XPathExpression<Element> xp =
XPathFactory.instance().compile("//contact_properties[@user_name='bashiro']",
Filters.element());
Element contactprops = xp.evaluateFirst(document);
contactprops.setAttribute("addess", "newaddress");
Technically you can go direct to the Attribute and do it like:
XPathExpression<Attribute> xp =
XPathFactory.instance().compile("//contact_properties/@address[../@user_name='bashiro']",
Filters.attribute());
Attribute address = xp.evaluateFirst(document);
address.setValue("newaddress");
Rolf
On 13/05/2012 7:08 AM, Bashiro wrote:
> Hello,
>
> I wonder if one has the following in XML file example;
>
> <contact_properties user_name="bashiro" address="here" phone="3333"
hobby="dGVzdDI" />
> <contact_properties user_name="test" address="there" phone="444"
hobby="dGVzdDIno" />
> <contact_properties user_name="test2" address="there 2" phone="4446"
hobby="-dGVzdDIno" />
>
> Username is unique so its the primary Key.
>
> If I want to edit address of say bashiro, I search for bashiro and when
found, the address attributes of bashiro is set to the
> new attributes.
> My question is; should the whole bashiro be removed and then the new
attributes set, or one can simply edit only address ?
>
> Bashiro
> Drammen-Norway
>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/[email protected]
>
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]