mavrosxristoforos / get-xml-info

Get Information from XML files to use into your GitHub workflows
GNU General Public License v3.0
6 stars 13 forks source link

Support read attribute #7

Closed nhan-nguyen-se closed 2 years ago

nhan-nguyen-se commented 2 years ago

Supports to read attribute value.

For example, given the xml file as below

<plugin key="plugin-key">content</plugin>

xPath //plugin/@key will return plugin-key

With current implementation it throws error:

Welcome to Get-XML-Version.
File to read: ./atlassian-plugin.xml
XPath: /atlassian-plugin/@key
File was read successfully. Proceeding to parse DOM.
Found 1 nodes.
/Users/debt/Workspace/get-xml-info/index.js:43
          output.push(firstChild.data);
                                 ^

TypeError: Cannot read property 'data' of null
    at read (/Users/debt/Workspace/get-xml-info/index.js:43:34)
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
nhan-nguyen-se commented 2 years ago

@mavrosxristoforos Can you consider to review this PR?

mavrosxristoforos commented 2 years ago

@nhan-nguyen-se Brilliant. Merging now!