script isn't really necessary since
\\ will traverse the entire structure and return those elements that match.
xml \\ "script" res1: scala.xml.NodeSeq = NodeSeq(<script id="ssl-cert" output="placeholder text"> ...
script tags in
res1.foreach(println(_)) <script id="ssl-cert" output="placeholder text"> <table key="subject"> ...
Update regarding comments
To get only the
port nodes that contain
(xml \\ "ports" \\ "port").filter(n => n.descendant.exists(_.label == "script"))
res81: scala.xml.NodeSeq = NodeSeq(<port protocol="tcp" portid="443"> <state state="open" reason="syn-ack" reason_ttl="0"/> <service name="https" method="table" conf="3"/> <script> <table key="subject"> ...
descendant gives a
List[Node] which is one way to do it. There are others but that worked for me.
- Processing XML document
- How do I parse an xml document as a stream using Scala?
- An example of xml processing but using anti-xml instead of Scala xml
- How do you add xml document info with scala.xml?
- Processing optional xml attributes in Scala
- Scala embed nested XML document in PCDATA
- How to read and output XML processing instructions in Scala?
- Tutorial on functional XML pull processing
- How do I obtain the DOCTYPE of an XML document in Scala?
- Scala XML processing is skipping a value
- Processing XML string inside Spark UDF and return Struct Field
- ConstructingParser: Could not load valid XML document from File
- Scala XML processing
- Scala - Processing XML to JSON Objects in Functional Style
- Formatted xml document type in scala
- complex custom schema for xml processing in spark
- Scala: XML Whitespace Removal?
- Scala - modifying nested elements in xml
- Construct XML with dynamic label and attributes in Scala?
- How to get ScalaTest to populate test runtimes in the xml report?
- Conditionally include attribute in XML literal
- Scala XML Building: Adding children to existing Nodes
- Removing nodes from XML
- How to produce nicely formatted XML in Scala?
- How to change attribute on Scala XML Element
- Functional processing of Scala streams without OutOfMemory errors
- dpkg: error processing package oracle-java8-installer (--configure):
- Writing a functional and yet functional image processing library in Scala
- Wait on asynchronous Future call before processing next message in Akka
- State of XML support in Scala 2.9.x
More Query from same tag
- Scala convert string between two charsets
- Can function parameter be set before it's invoked?
- Scala Function Currying and call By name Functions, GenricTypes
- Update a highly nested column from string to struct
- Is there Scala aware high level byte-code manipulation tool like Javassist?
- How to call an item in an array using a variable in Scala?
- reuse the result of a select expression in the "GROUP BY" clause?
- Why does this example miss one Future result?
- Provider com.google.cloud.spark.bigquery.BigQueryRelationProvider could not be instantiated while reading from bigquery in Jupyter lab
- Is there a nicer way of lifting a PartialFunction in Scala?
- Syntax sugar: _* for treating Seq as method parameters
- How to call remote SQL function inside PySpark or Scala databriks notebook
- Respond to message received by TestProbe
- How can I tell what Scala version a .class file was compiled with?
- BufferedStream chaining Scala (or Java)
- Flattening mixed nested monads in cats (composing complex Kleislis)
- Compiler generated function class in Scala
- Iterate over the fields of an object
- Serializing a priority queue in scala
- Spark Bzip2 compression ratio is not efficient
- covariant type A occurs in contravariant position in type A of value a
- How can I create one copy of a piece of data per subclass?
- Is getting the length of a Sequence a constant-time operation?
- Why does starting StreamingContext fail with "IllegalArgumentException: requirement failed: No output operations registered, so nothing to execute"?
- Match for isInstanceOf
- Scala trait as a function return type
- How to get the difference between minimum and maximum stock for each product?
- What is the best way to run a Java program that also has Scala code?
- working with class as function parameter in Scala
- Unable to print line or reach break point in Gatling 3.0 simulation