-1

I am hoping if anyone can help me on searching "password" info from my xml file using xmllint command. here is my xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="urn:jboss:domain:1.4">
    <extensions>
        <extension module="org.jboss.as.clustering.infinispan"/>
        <extension module="org.jboss.as.configadmin"/>
        <extension module="org.jboss.as.connector"/>
        <extension module="org.jboss.as.weld"/>
    </extensions>
    <profile>
        <subsystem xmlns="urn:jboss:domain:logging:1.2">
            <size-rotating-file-handler name="FILE">
                <formatter>
                    <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
                </formatter>
            </size-rotating-file-handler>
        </subsystem>
        <subsystem default-virtual-server="default-host" native="false" xmlns="urn:jboss:domain:web:1.4">
            <connector enable-lookups="false" name="https"
                protocol="HTTP/1.1" scheme="https" secure="true" socket-binding="https">
                <ssl
                    certificate-key-file="${jboss.server.config.dir}/apollo.keystore"
                    cipher-suite="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384"
                    key-alias="${apollo.keystore.alias:apollokey}"
                    keystore-type="PKCS12" name="ssl"
                    password="Here is what I want to search"
                    protocol="TLSv1.2" verify-client="false"/>
            </connector>
            <virtual-server enable-welcome-root="false" name="default-host">
                <alias name="localhost"/>
                <alias name="example.com"/>
            </virtual-server>
        </subsystem>
    </profile>
</server>

I am hoping if anyone can help me out to parse this kind of xml file. thanks

Daniel Haley
  • 51,389
  • 6
  • 69
  • 95
Jerry Jie
  • 1
  • 2

1 Answers1

0

You don't show what xmllint command you're using so it's hard to say exactly what you're doing wrong, but my guess is that you're not accounting for the default namespace.

See this answer for a couple of ways to handle namespaces in xmllint: https://stackoverflow.com/a/8266075/317052

Here's another option that doesn't require you to know the namespace uri...

xmllint --xpath "string(//*[@password]/@password)" input.xml

This will output:

Here is what I want to search
Daniel Haley
  • 51,389
  • 6
  • 69
  • 95