sweet_xml icon indicating copy to clipboard operation
sweet_xml copied to clipboard

xpath(~x"/some/path"l) transforms :xmlText nodes into char lists

Open sllvn opened this issue 8 years ago • 1 comments

"<p>some nested <em>node</em> content</p>" |> xpath(~x"/node()/node()"l)

returns

['some nested ',
 {:xmlElement, :em, :em, [], {:xmlNamespace, [], []}, [p: 1], 2, [],
  [{:xmlText, [em: 2, p: 1], 1, [], 'node', :text}], [],
  '/some/directory', :undeclared}, ' content']

instead of

[{:xmlText, [p: 1], 1, [], 'some nested ', :text},
 {:xmlElement, :em, :em, [], {:xmlNamespace, [], []}, [p: 1], 2, [],
  [{:xmlText, [em: 2, p: 1], 1, [], 'node', :text}], [],
  '/some/directory', :undeclared},
 {:xmlText, [p: 1], 3, [], ' content', :text}]

Note how the text nodes have been unwrapped into char-lists. Is this correct behavior? I'm running into this issue when passing an element around via transform_by and performing further matching.

Thanks!

sllvn avatar Apr 28 '16 16:04 sllvn

Try xpath(~x"/node()/node()"sl)

sintro avatar Aug 15 '17 11:08 sintro