antchfx / xmlquery

xmlquery is Golang XPath package for XML query.

Home Page:https://github.com/antchfx/xpath

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to deal with spaces?

GAZ082 opened this issue · comments

Hey there. I have a record like this:

  <property>
    <Field name="prop_id">1593</Field>
    <Field name="prop_label">XA_PCV_P_11</Field>
    <Field name="prop_entity_type">1</Field>
    <Field name="prop_name">Opening pressure</Field>
    <Field name="Property ID">1593</Field>
    <Field name="Property Language">1</Field>
    <Field name="Text Entry Identifier">0</Field>
  </property>

And would like to get the Property Language value among others. How can I deal with the space "Property Language" has?

Currently Im trying this:

XMLPath := fmt.Sprintf(`/properties/property[Field[@name='prop_label']='%v']/Field[@name='prop_id' or @name='prop_name or @name="Property Language"']`, propLabel)

Already t ried with double quotes, three single quotes, etc. etc. to no avail.

Any tip? Thanks!

I didn't understand what you mean? The "//Field[@name='Property Language']" can works.

Had single quotes missing, this worked:

	XMLPath := fmt.Sprintf(`/properties/property[Field[@name='prop_label']='%v']/Field[@name='prop_id' or @name='prop_name' or @name='Property Language']`, propLabel)