Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting in README.md #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ JSFiddle at http://jsfiddle.net/abdmob/gkxucxrj/1/

## XML to JSON

```
```js
// Create x2js instance with default config
var x2js = new X2JS();
var xmlText = "<MyRoot><test>Success</test><test2><item>val1</item><item>val2</item></test2></MyRoot>";
Expand All @@ -50,7 +50,7 @@ var jsonObj = x2js.xml_str2json( xmlText );

## JSON to XML

```
```js
// Create x2js instance with default config
var x2js = new X2JS();
var jsonObj = {
Expand All @@ -68,7 +68,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Configure XML structure knowledge beforehand

```
```js
var x2js = new X2JS({
arrayAccessFormPaths : [
"MyArrays.test.item"
Expand All @@ -86,7 +86,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Or using the utility function

```
```js
var x2js = new X2JS();
var xmlText = "<MyArrays>"+
"<test><item>success</item><item>second</item></test>"+
Expand All @@ -99,7 +99,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Accessing to XML attributes

```
```js
// Create x2js instance with default config
var x2js = new X2JS();

Expand All @@ -117,7 +117,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Configuring a custom prefix to attributes

```
```js
var x2js = new X2JS({
attributePrefix : "$"
});
Expand All @@ -134,7 +134,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Parsing XML with namespaces

```
```js
var xmlText = "<testns:MyOperation xmlns:testns='http://www.example.org'>"+
"<test>Success</test><test2 myAttr='SuccessAttrValueTest2'>"+
"<item>ddsfg</item><item>dsdgfdgfd</item><item2>testArrSize</item2></test2></testns:MyOperation>";
Expand All @@ -145,7 +145,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Creating JSON (for XML) with namespaces (Option 1)

```
```js
var testObjC = {
'm:TestAttrRoot' : {
'_tns:m' : 'http://www.example.org',
Expand All @@ -162,7 +162,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Creating JSON (for XML) with namespaces (Option 2)

```
```js
// Parse JSON object constructed with another NS-style
var testObjNew = {
TestAttrRoot : {
Expand All @@ -186,7 +186,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Configuring it beforehand

```
```js
var x2js = new X2JS({
datetimeAccessFormPaths : [
"MyDts.testds" /* Configure it beforehand */
Expand All @@ -201,7 +201,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Or using the utility function

```
```js
var x2js = new X2JS();

var xmlText = "<MyDts>"+
Expand All @@ -216,7 +216,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Parsing AJAX XML response (JQuery sample)

```
```js
$.ajax({
type: "GET",
url: "/test",
Expand All @@ -231,7 +231,7 @@ var xmlAsStr = x2js.json2xml_str( jsonObj );

## Loading XML and converting to JSON

```
```js
function loadXMLDoc(dname) {
if (window.XMLHttpRequest) {
xhttp=new XMLHttpRequest();
Expand Down