0

I'm trying to convert xml to json for processing in AngularJS can't make it work.

demo here

I guess i need to put source for x2js

<script src="bower_components/x2js/xml2json.js"></script>

<script src="bower_components/angular-x2js/src/x2js.js"></script>

but don't know where to put in jsFiddle

As output i need json in form of HTML table

5
  • You have to add it under "External Resources" in the left pane. Commented Dec 10, 2015 at 6:13
  • @JiaJian i did that but still can't make it work Commented Dec 10, 2015 at 6:17
  • 1
    Check a working jsFiddle like this one jsfiddle.net/abdmob/gtLBx/15 and also you can try to use a x2js wrapper for Angular github.com/cesarbarone/angular-x2js Commented Dec 10, 2015 at 7:52
  • I've updated your jsFiddle jsfiddle.net/16tph2sx/7 Commented Dec 10, 2015 at 10:04
  • @beaver thanks! but html table isn't come out of that Commented Dec 10, 2015 at 10:20

1 Answer 1

1

Here is another jsFiddle which convert your XML into JSON and via ng-repeat shows it in an HTML table:

http://jsfiddle.net/beaver71/n8ov74oe/

Note that the JSON obtained from you XML has the following form:

var json = {
    "Table" : {
        "Row" : [{
                "Cell" : [{
                        "_cellWidth" : "937",
                        "__text" : "Cat. No."
                    }, ...
                ],
                "_cellSize" : "9"
                },
                {
                "Cell" : [{
                        "_cellWidth" : "937",
                        "__text" : "11"
                    }, ...
                ],
                "_cellSize" : "9"
            }
        ]
    }
};

so real data are in json.Table.Row

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.