MCPcopy Create free account
hub / github.com/antchfx/xmlquery / CreateStreamParserWithOptions

Function CreateStreamParserWithOptions

parse.go:454–479  ·  view source on GitHub ↗

CreateStreamParserWithOptions is like CreateStreamParser, but with custom options

(
	r io.Reader,
	options ParserOptions,
	streamElementXPath string,
	streamElementFilter ...string,
)

Source from the content-addressed store, hash-verified

452
453// CreateStreamParserWithOptions is like CreateStreamParser, but with custom options
454func CreateStreamParserWithOptions(
455 r io.Reader,
456 options ParserOptions,
457 streamElementXPath string,
458 streamElementFilter ...string,
459) (*StreamParser, error) {
460 elemXPath, err := getQuery(streamElementXPath)
461 if err != nil {
462 return nil, fmt.Errorf("invalid streamElementXPath '%s', err: %s", streamElementXPath, err.Error())
463 }
464 elemFilter := (*xpath.Expr)(nil)
465 if len(streamElementFilter) > 0 {
466 elemFilter, err = getQuery(streamElementFilter[0])
467 if err != nil {
468 return nil, fmt.Errorf("invalid streamElementFilter '%s', err: %s", streamElementFilter[0], err.Error())
469 }
470 }
471 parser := createParser(r)
472 options.apply(parser)
473 sp := &StreamParser{
474 p: parser,
475 }
476 sp.p.streamElementXPath = elemXPath
477 sp.p.streamElementFilter = elemFilter
478 return sp, nil
479}
480
481// Read returns a target node that satisfies the XPath specified by caller at
482// StreamParser creation time. If there is no more satisfying target nodes after

Callers 1

CreateStreamParserFunction · 0.85

Calls 3

getQueryFunction · 0.85
createParserFunction · 0.85
applyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…