Skip to content

Instantly share code, notes, and snippets.

@h26k2
Created February 28, 2020 15:09
Show Gist options
  • Save h26k2/612252bd9d21ea62c81df16aa738be2c to your computer and use it in GitHub Desktop.
Save h26k2/612252bd9d21ea62c81df16aa738be2c to your computer and use it in GitHub Desktop.
A short gist for analyzing my xpath
let str = `BODY[5]/DIV[2]/DIV[0]/DIV[0]/DIV[0]`;
let indexes = [];
let elems = str.split("/");
let temp_index = [];
Array.from(elems).forEach((elem)=>{
let s = elem.indexOf(`[`) + 1;
let e = elem.length - 1;
temp_index.push(parseInt(elem.substr(s,e)));
});
indexes.push([...temp_index]);
console.log(indexes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment