Have anyone tried this code before?
有没有人以前试过这个代码?
XmlSource<String> source = XmlSource.<String>from("gs://balajee_test/sample_3.xml")
.withRootElement("book")
.withRecordElement("author")
.withRecordElement("title")
.withRecordElement("genre")
.withRecordElement("price")
.withRecordElement("description")
.withRecordClass(XMLFormatter.class);
PCollection<String> output = p.apply(Read.from(source));
https://beam.apache.org/documentation/sdks/javadoc/0.4.0/org/apache/beam/sdk/io/XmlSource.html
https://beam.apache.org/documentation/sdks/javadoc/0.4.0/org/apache/beam/sdk/io/XmlSource.html
org.apache.beam.sdk.io.xml.XmlSource
org.apache.beam.sdk.io.xml.XmlSource
Hope I'm using the correct 'XmlSource' class but still not able to resolve dependencies for method 'from("gs://balajee_test/sample_3.xml")' and getting compilation error for the same. The error message is :
希望我使用正确的'XmlSource'类,但仍然无法解决方法'from(“gs://balajee_test/sample_3.xml”)'的依赖关系并获得相同的编译错误。错误消息是:
The method from(String) is undefined for the type XmlSource
对于类型XmlSource,未定义(String)方法
This question may go too silly but I really need to get it resolved in order to be able to read XML File stored in GCS Bucket.
这个问题可能太愚蠢但我真的需要解决它才能读取存储在GCS Bucket中的XML文件。
1 个解决方案
#1
0
From comments, seem that the SDK used is 2.0 which has a new way to define a read from XML. Check the new documentation for how to read.
从评论来看,似乎使用的SDK是2.0,它有一种新的方法来定义XML的读取。查看新文档以了解如何阅读。
SDK IO documentation (for 2.0.0) can be found here: beam.apache.org/documentation/sdks/javadoc/2.0.0
可以在此处找到SDK IO文档(适用于2.0.0):beam.apache.org/documentation/sdks/javadoc/2.0.0
#1
0
From comments, seem that the SDK used is 2.0 which has a new way to define a read from XML. Check the new documentation for how to read.
从评论来看,似乎使用的SDK是2.0,它有一种新的方法来定义XML的读取。查看新文档以了解如何阅读。
SDK IO documentation (for 2.0.0) can be found here: beam.apache.org/documentation/sdks/javadoc/2.0.0
可以在此处找到SDK IO文档(适用于2.0.0):beam.apache.org/documentation/sdks/javadoc/2.0.0