我一直在使用class.The输出如何从给定的字符串获取子字符串?
String result=<?xml version="1.0"?><catalog><book id="bk101"><part1><date>Fri Apr 05 11:46:46 IST 2013</date><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price> <publish_date>2000-10-01</publish_date></part1></book></catalog>
现在我想先更换日期value.so我想从字符串中提取日期和更换新value.I读取整个XML文件作为单一字符串具有以下代码,
Date date=new Date()
String str=result.substring(result.indexOf("<date>"));
它显示从日期标记到结束标记的整个字符串。 如何提取日期标记并将其替换?
为什么不使用内置的XML解析API? – MadProgrammer 2013-04-05 09:23:53
String str = result.substring(result.indexOf(“”),result.indexOf(“ ”)); –
2013-04-05 09:25:46
你可以使用正则表达式 – 2013-04-05 09:26:24