Hi,
I have an xml file with a few attributes, e.g. <draw:image draw:style-
name="id4" ... >
Now, what I would like to do is replace all semi-colons with hyphens ("-").
For the tag-name itself this isn't really a problem, since I can check
wheater a "<" preceeds the tag, but for the attributes it is, since not all
attributes appear always, nor in the same order. I tried something like
this:
XML = XML.replaceAll("<[^>]*draw:style-name=\"","<[^>]*draw-style-name=
\"");
but in the result, the "[^>]*" string is being added, instead of the
preceeding text that was there before. Is there a way to make sure the rest
of the text stays in place?
TIA
Nicholas Pappas - 27 May 2004 14:54 GMT
> Now, what I would like to do is replace all semi-colons with hyphens ("-").
The String class has a replace function which should do what you want.
String xmlString = "<draw:image draw ... >"
String xmlCleaned;
xmlCleaned = xmlString.replace(';', '-');
wEEdpEckEr - 31 May 2004 09:16 GMT
> The String class has a replace function which should do what you
> want.
>
> String xmlString = "<draw:image draw ... >"
> String xmlCleaned;
> xmlCleaned = xmlString.replace(';', '-');
euh, yeah, well, that's a little too simple, you see. In between the tags
can be regular text, e.g.
"<text:p>Some text: and other text</text:p>"
and I don't want the text to be changed. That's why I have to check if
there are "<" and ">" before and after the colon (not semi-colon, sorry,
confusing names for none English speaking persons).
greetz
Tim