jQWidgets Forums

jQuery UI Widgets Forums Grid jqxgrid with xml data from Splunk, using php

This topic contains 2 replies, has 2 voices, and was last updated by  kathyl 6 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • kathyl
    Participant

    I’m putting together a grid with xml data that has been exported from splunk using php. I am having a problem with getting the data to display.

    My xml looks like this:

    
    <?xml version='1.0' encoding='UTF-8'?>
    <results preview = '0'>
        <result offset='0'>
            <field k='hostname'>
              <value h='1'><text>Hostname 1</text></value>
            </field>
            <field k='os'>
              <value><text>Windows 7</text></value>
            </field>        
            <field k='location'>
              <value h='1'><text>Building 1</text></value>
        </result>
       <result offset='1'>
            <field k='hostname'>
              <value h='1'><text>Hostname 2</text></value>
            </field>
            <field k='os'>
              <value><text>Windows 10</text></value>
            </field>        
            <field k='location'>
              <value h='1'><text>Building 2</text></value>
            </field>
         </result>
        ........
    

    The valid parts of my js (setting the grid up) are below:

    ` var source =
    {
    datatype: “xml”,
    datafields: [
    { name: ‘Hostname’, map: ‘m:<field k><value h=”1″><text>’ },
    { name: ‘OS’, map: ‘<field k><value h><text>’ },
    { name: ‘Location’, map: ‘<field k><value h=”1″><text>’ }

    ],
    root: “results preview”,
    record: “result offset”,
    id: “field k=’hostname'”,
    url: data.xml,
    …..
    `

    The rest of the files are the standard jqxGrid code. The grid itself displays, but of course it says No data to display. The response payload in the browser just displays the xml file.

    I’m guessing that my map set up is not correct. I have read the other xml questions and examples here, but this xml seems a bit odd to me (and I cannot change it).

    Any help would be appreciated.


    Hristo
    Participant

    Hello kathyl,

    It is a little bit strange case.
    I saw a missing </field> tag.
    Please, take a look at this topic if you did not:
    https://www.jqwidgets.com/community/topic/binding-datatable-to-xml-attribute/#post-48916

    Also, I would like to suggest you look at this example.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    kathyl
    Participant

    Thank you so much! It works like a charm – appreciate the help.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.