0

I have an XML values stored in one of the Lotus Notes field(consider it as a normal XML).

I have 'row id' in my XML and I want to read the values of it in javascript. in my XML it is appearing twice, I want to read both the values

My XML is given below

<rows>
   <row id="1295627144000">
      <cell>1</cell>
      <cell>1134894</cell>
      <cell>3000</cell>
      <cell>0</cell>
      <cell>hit</cell>
      <cell>INR</cell>
      <cell>CAP</cell>
      <cell>
         <IMG title="" src="http://localhost/test/preview/test.nsf/application_form_edit.png" />
      </cell>
      <cell>100%</cell>
      <cell>S</cell>
      <cell>3000000</cell>
      <cell>No</cell>
      <cell />
      <cell>Standard Char</cell>
      <cell>001</cell>
   </row>
   <row id="1312205523000">
      <cell>2</cell>
      <cell>1134894</cell>
      <cell>400000000</cell>
      <cell>3000000</cell>
      <cell>hit</cell>
      <cell>hit</cell>
      <cell>CAP</cell>
      <cell>
         <IMG title="" src="http://localhost/test/preview/test.nsf/application_form_edit.png" />
      </cell>
      <cell>40%</cell>
      <cell>S</cell>
      <cell>160000000</cell>
      <cell>Yes</cell>
      <cell />
      <cell>Hors Bourse</cell>
      <cell>001</cell>
   </row>
</rows>
James Z
  • 12,209
  • 10
  • 24
  • 44
Azhar
  • 1
  • 2
  • Hi, welcome to stack overflow. Please edit your question to include the section of XML formatted as code so we can read it properly – Spangen Jan 17 '18 at 07:58
  • Kindly share the efforts you have put so far and what results you have achieved if you have tried it – Mudassar Jan 17 '18 at 08:13
  • Possible duplicate of [reading XML attributes in javascript](https://stackoverflow.com/questions/15329878/reading-xml-attributes-in-javascript) – Bourbia Brahim Jan 17 '18 at 08:17

1 Answers1

0

you can create an element and set its content with your xml. Then you can use querySelectorAll on this new element to fetch 'row' elements:

var unknown = document.createElement('unknown');
unknown.innerHTML = `<rows>
     <row id="1295627144000">
      <cell>1</cell>
      <cell>1134894</cell>
      <cell>3000</cell>
      <cell>0</cell>
      <cell>hit</cell>
      <cell>INR</cell>
      <cell>CAP</cell>
      <cell>
       <IMG title="" src="http://localhost/test/preview/test.nsf/application_form_edit.png" />
      </cell>
      <cell>100%</cell>
      <cell>S</cell>
      <cell>3000000</cell>
      <cell>No</cell>
      <cell />
      <cell>Standard Char</cell>
      <cell>001</cell>
   </row>
   <row id="1312205523000">
      <cell>2</cell>
      <cell>1134894</cell>
      <cell>400000000</cell>
      <cell>3000000</cell>
      <cell>hit</cell>
      <cell>hit</cell>
      <cell>CAP</cell>
      <cell>
       <IMG title="" src="http://localhost/test/preview/test.nsf/application_form_edit.png" />
      </cell>
      <cell>40%</cell>
      <cell>S</cell>
      <cell>160000000</cell>
      <cell>Yes</cell>
      <cell />
      <cell>Hors Bourse</cell>
      <cell>001</cell>
     </row>
   </rows>`;
  console.log(unknown.querySelectorAll('row'));
Okoch
  • 445
  • 2
  • 5