我正在尝试使用VBA解析文本文档并返回文本文件中给出的路径.
例如,文本文件看起来像:
*Blah blah instructions
*Blah blah instructions on line 2
G:\\Folder\...\data.xls
D:\\AnotherFolder\...\moredata.xls
Run Code Online (Sandbox Code Playgroud)
我希望VBA一次加载1行,如果它以a开头,*则移动到下一行(类似于被注释的那行).对于带有文件路径的行,我想将该路径写入单元格,例如A2第一条路径,B2下一条路径等.
我希望回答的主要内容是:
1.使用VBA读取文本文件的最佳/简单方法是什么?
2.我该如何逐行完成?
我正在尝试解析我制作的XML文件并从中提取信息.我基于本教程.解析连接到XML文件ok并评估第一个标记,但之后会在输出中看到崩溃.下面附有XML文件布局,Java解析代码和控制台输出.
知道为什么它不读取XML的下一个标签,如果是这样,我应该改变什么?
XML文件:
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<filepath>/mnt/sdcard/Audio_Recorder/anonymous22242.3gp</filepath>
<filename>anonymous22242.3gp</filename>
<annotation>
<file>anonymous22242.3gp</file>
<timestamp>0:06</timestamp>
<note>test1</note>
</annotation>
<annotation>
<file>anonymous22242.3gp</file>
<timestamp>0:09</timestamp>
<note>lol</note>
</annotation>
<annotation>
<file>anonymous22242.3gp</file>
<timestamp>0:09</timestamp>
<note>lolol</note>
</annotation>
Run Code Online (Sandbox Code Playgroud)
Java文件:
private static String fileDirectory;
private final static ArrayList<String> allFileNames = new ArrayList<String>();
private final static ArrayList<String[]> allAnnotations = new ArrayList<String[]>();
private static String[] currentAnnotation = new String[3];
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser playbackParser = factory.newSAXParser();
DefaultHandler handler = new …Run Code Online (Sandbox Code Playgroud) 我有一个XML文件,如下所示:
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<allinfo>
<filepath>/mnt/sdcard/Audio_Recorder/</filepath>
<filename>newxml35500.3gp</filename>
<annotation>
<file>newxml35500.3gp</file>
<timestamp>0:05</timestamp>
<note>uuuouou</note>
</annotation>
<filepath>/mnt/sdcard/Audio_Recorder/</filepath>
<filename>newxml35501.3gp</filename>
<annotation>
<file>newxml35501.3gp</file>
<timestamp>0:04</timestamp>
<note>tyty</note>
</annotation>
</allinfo>
Run Code Online (Sandbox Code Playgroud)
我正在尝试在创建XML之后向XML添加一个附加注释,因此XML还有一个附加注释:
<annotation>
<file>blah</file>
<timestamp>0:00</timestamp>
<note>this is a note</note>
</annotation>
Run Code Online (Sandbox Code Playgroud)
找到根然后在Java中用XML写几行的最佳方法是什么?我已经看到DocumentBuilderFactory从其他人那里获得了一些用处,但我不确定如何正确实现它.任何帮助将非常感激.