Hi all,

the init.xml file has among its lines, one line as <guid>5934</guid>

init.xml
-------------------
-------------------
<guid>5934</guid>
-------------------
------------------

I need to increment the guid every time I modify the file. Could any one please tell me how to do that.

Regards,
Prashanth

What have you tried?

You can use Regular Expressions.
Search the file for that pattern, get the "guid" number, increment it by one, then write it.
I haven't done regex in a while, so I'm not sure about the syntax.

Well, the first thing is that [URL="http://dirtsimple.org/2004/12/python-is-not-java.html"]"XML is not the answer"[/URL]. If you need to allow people to edit the file by hand; or if you are supporting an existing system, then maybe. Otherwise, I strongly suggest you use something else (pickle file? Python format config file?, simple ini type layout?).

Assuming you are stuck with this, I would either use an xml parser or a regular expression to find and replace the guid value. Be aware that since this is a text file, users [B]can[/B] hand edit it, so you cannot count on the exact format (there might be an added or missing line break, extra white space, comments ...)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.