T
ten8ciousb
Tried this over at mozilla.dev.tech but didn't get any bites.
I know can return a list of nodes, but I want to get a specific
value.
given this xml
var phoneList = <table>
<row>
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
<EMPLOYEE-NAME>Jim Halpert</EMPLOYEE-NAME>
<EMPLOYEE-PHONE>555-555-5555</EMPLOYEE-PHONE>
</row>
<row>
<COMPANY-NAME>INNOTECH</COMPANY-NAME>
<EMPLOYEE-NAME>Peter Gibbons</EMPLOYEE-NAME>
<EMPLOYEE-PHONE>555-444-4444</EMPLOYEE-PHONE>
</row>
<row>
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
<EMPLOYEE-NAME>Dwight Schroot</EMPLOYEE-NAME>
<EMPLOYEE-PHONE>555-555-5550</EMPLOYEE-PHONE>
</row>
</table>;
if I want to get only the DUNDER MIFFLIN records, I can't use
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN")
because the hyphen is used as a minus and I get an error about NAME
not
being defined or something.
I know that I can get a list of all the "COMPANY-NAME" nodes using
phoneList..row["COMPANY-NAME"];
-or-
phoneList...row.descendants("COMPANY-NAME");
those both return:
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
<COMPANY-NAME>INNOTECH</COMPANY-NAME>
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
Is there a way to filter the list? How can I just the DUNDER MIFFLIN
list? i.e., how can I do this?
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN");
And to take it a step further. Just get the list of Dunder Mifflin
employees. How
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN").EMPLOYEE-NAME;
and ultimately the phone number for a specific employee at a specific
company.
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN" && EMPLOYEE-NAME ==
"Jim Halpert").EMPLOYEE-PHONE;
I have tried variations but haven't found one that let's me filter on
the content
I know can return a list of nodes, but I want to get a specific
value.
given this xml
var phoneList = <table>
<row>
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
<EMPLOYEE-NAME>Jim Halpert</EMPLOYEE-NAME>
<EMPLOYEE-PHONE>555-555-5555</EMPLOYEE-PHONE>
</row>
<row>
<COMPANY-NAME>INNOTECH</COMPANY-NAME>
<EMPLOYEE-NAME>Peter Gibbons</EMPLOYEE-NAME>
<EMPLOYEE-PHONE>555-444-4444</EMPLOYEE-PHONE>
</row>
<row>
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
<EMPLOYEE-NAME>Dwight Schroot</EMPLOYEE-NAME>
<EMPLOYEE-PHONE>555-555-5550</EMPLOYEE-PHONE>
</row>
</table>;
if I want to get only the DUNDER MIFFLIN records, I can't use
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN")
because the hyphen is used as a minus and I get an error about NAME
not
being defined or something.
I know that I can get a list of all the "COMPANY-NAME" nodes using
phoneList..row["COMPANY-NAME"];
-or-
phoneList...row.descendants("COMPANY-NAME");
those both return:
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
<COMPANY-NAME>INNOTECH</COMPANY-NAME>
<COMPANY-NAME>DUNDER MIFFLIN</COMPANY-NAME>
Is there a way to filter the list? How can I just the DUNDER MIFFLIN
list? i.e., how can I do this?
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN");
And to take it a step further. Just get the list of Dunder Mifflin
employees. How
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN").EMPLOYEE-NAME;
and ultimately the phone number for a specific employee at a specific
company.
phoneList..row.(COMPANY-NAME == "DUNDER MIFFLIN" && EMPLOYEE-NAME ==
"Jim Halpert").EMPLOYEE-PHONE;
I have tried variations but haven't found one that let's me filter on
the content