XMLWriter - writeEndElement not working

I am using the XMLWriter to create an xml output that I'll be using to communicate to an API.

My code is show below:

var v = new XMLWriter(); v.writeStartDocument(true); v.writeElementString('invoice_date', '2011-04-01T00:00:00Z'); v.writeStartElement('invoice_lines'); v.writeAttributeString( 'type', 'array'); v.writeStartElement('invoice_line'); v.writeElementString('product_id', '54'); v.writeElementString('quantity', '1'); v.writeElementString('retail_price', '100'); v.writeEndElement(); v.writeEndElement(); v.writeStartElement('payments'); v.writeAttributeString( 'type', 'array'); v.writeStartElement('payment'); v.writeElementString('amount', '100'); v.writeEndElement(); v.writeEndElement(); v.writeEndDocument();

The result of the code above is:

<?xml version="1.0" encoding="ISO-8859-1" standalone="true" ?> <invoice_date> 2011-04-01T00:00:00Z <invoice_lines type="array"> <invoice_line> <product_id>54</product_id> <quantity>1</quantity> <retail_price>100</retail_price> </invoice_line> </invoice_lines> <payments type="array"> <payment> <amount>100</amount> </payment> </payments> </invoice_date>

I am expecting the output to be like this:

<?xml version="1.0" encoding="ISO-8859-1" standalone="true" ?> <invoice> <invoice_date>2011-04-01T00:00:00Z</invoice_date> <invoice_lines type="array"> <invoice_line> <product_id>54</product_id> <quantity>1</quantity> <retail_price>100</retail_price> </invoice_line> </invoice_lines> <payments type="array"> <payment> <amount>100</amount> </payment> </payments> </invoice>

What is wrong with my code? Please help.

Category:javascript Views:2 Time:2018-08-09

Related post

  • XDocument Saving Error in Mono "This XmlWriter does not accept Text at this state Prolog." 2012-02-03

    I am trying to save an xml document, and I have been trying to get my code to work but mono is spitting out a very strange error. I have given the file it is trying to save to full ownership. An example would be group.test.test to "Hello world!" Here

  • __doPostBack is not working in firefox 2008-09-10

    The __doPostBack is not working in firefox 3 (have not checked 2). Everything is working great in IE 6&7 and it even works in Chrome?? It's a simple asp:LinkButton with an OnClick event <asp:LinkButton ID="DeleteAllPicturesLinkButton" Enabled=

  • Random in python 2.5 not working? 2008-09-16

    I am trying to use the import random statement in python, but it doesn't appear to have any methods in it to use. Am I missing something? --------------Solutions------------- You probably have a file named random.py or random.pyc in your working dire

  • Page index is not working 2008-09-17

    Help me ..my page index is not working in visual studio. my page load is as follows: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CustomerView.DataSource = Customer.GetAll(); CustomerView.DataBind(); } } protected vo

  • YouTube embeds not working in WordPress after import from Blogger 2008-09-21

    I imported a series of blog posts from blogger to WordPress, and the YouTube embed tags were stripped away. Now I just have the YouTube URLs in the posts, as opposed to the complete embed tags. I am trying to restore the embed codes. --------------So

  • JQuery Flickr file upload not working 2008-09-29

    I am trying to upload a file using to Flickr using JQuery. I have a form (which works if I dont use JQuery) which I am submitting using the Form Plugin. My code is as follows: <html> <head> <title>Test Upload</title> <scrip

  • not working in firefox and chrome 2008-10-01

    break line tag is not working in firefox, neither in chrome. When i see the source of my page i get: <p>Zugang zu Testaccount:</br></br>peter petrelli </br></br>sein Standardpwd.</br></br>peter.heroes.com<

  • Excel 2003 XML format - AutoFitWidth not working 2008-10-05

    I have a program that spits out an Excel workbook in Excel 2003 XML format. It works fine with one problem, I cannot get the column widths to set automatically. A snippet of what I produce: <Table > <Column ss:AutoFitWidth="1" ss:Width="2"/

  • Why does Eclipse code completion not work on some projects? 2008-10-07

    I have Eclipse 3.3.2 with PDT doing PHP development. All projects that I create, even SVN projects have code completion. Now I just opened another SVN project and it has no code completion or PHP templates (CTRL-space does nothing in that project). H

  • Boolean 'NOT' in T-SQL not working on 'bit' datatype? 2008-10-07

    Trying to perform a single boolean NOT operation, it appears that under MS SQL Server 2005, the following block does not work DECLARE @MyBoolean bit; SET @MyBoolean = 0; SET @MyBoolean = NOT @MyBoolean; SELECT @MyBoolean; Instead, I am getting more s

  • Tab index not working properly 2008-10-08

    I have some controls in the tablelayoutpanel but the tab index for the control are not working properly. --------------Solutions------------- I don't know what your specific issue is because the question is a bit vague, but be aware that container co

  • When does CSS's !important declaration not work? 2008-10-09

    I am wondering if someone can put a bit of an authoritative reference summary of when the !important declaration in CSS does not work to override inline styles. --------------Solutions------------- There are many factors involved in determining which

  • jQuery resize not working at FireFox, Chrome and Safari 2008-10-23

    $("#dvMyDIV").bind("resize", function(){ alert("Resized"); }); or $("#dvMyDIV").resize(function(){ alert("Resized"); }); The questions Why is this not working at FireFox, Chrome and Safari? Can this be considered a jQuery bug since the resize is not

  • ActionLink not working but RouteUrl does 2008-10-26

    I have a route // Sample URL: /Fixtures/Team/id routes.MapRoute( "Fixtures-by-TeamID", "Fixtures/Team/{teamId}", new { controller = "Fixtures", action = "GetByTeamID", }, new { teamId = @"\d{1,3}" } ); and I am trying to use ActionLink in ASP.net MVC

  • HashSet.remove() and Iterator.remove() not working 2008-10-31

    I'm having problems with Iterator.remove() called on a HashSet. I've a Set of time stamped objects. Before adding a new item to the Set, I loop through the set, identify an old version of that data object and remove it (before adding the new object).

  • Why is the WebService not working? 2008-11-02

    function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres,OnSuccessTheatres,OnError,OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices,OnSuccessTicketPrices,OnError,OnTimeO

  • Drag and drop from Windows File Explorer onto a Windows Form is not working 2008-11-11

    I'm having an issue dragging a file from Windows Explorer on to a Windows Forms application. It works fine when I drag text, but for some reason it is not recognizing the file. Here is my test code: namespace WindowsFormsApplication1 { public partial

  • T4 not working in Visual Studio 2008 2008-11-14

    I have two machines setup to run Visual Studio 2008 (SP1) & NET Framework 3.5 (SP1). If I create a .tt file in a console appliaction on machine #1 it automatically creates the sub .cs file for me, however if I do the exact same on machine #2 then

  • wmv file not working in Firefox 3.0.3, Its working fine in IE 2008-11-17

    I am using following code to embed files, video with .wmv extension, that is not working in Firefox. It's working fine in IE. document.getElementById("QuestionMedia").innerHTML += '<OBJECT ID="MediaPlayer" WIDTH="350" HEIGHT="280" CLASSID="CLSID:2

  • .net image button click not working in internet explorer but working fine in mozilla 2008-11-18

    I have written c# code for ascx. I am trying to send an email on the click of image button. Please see the code below. Here is the codebehind function which is called on submit button click. <%@ Control Language="C#" %> <%@ Import Namespace=

  • as3 ExternalInterface.addCallback is not working right 2008-11-19

    I was trying to access swf from javascript, so this example in livedocs is what I'm trying to modify. http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#includeExamplesSummary However,it is not working cor

  • Some keys not working with a Dojo Widget 2008-11-22

    I tried to follow the widget example by mindtrove's blog. Here is the example demo page. There are some problems with this widget: left & right arrow keys, and home & end keys are not working in Firefox(I am using a Mac), and none of any keys

  • CreateProcessAsUser not working correctly in my experiments 2008-11-26

    I am trying to do the following: 1. I am logged in as Administrator account in my XP with SP2 machine running VS.NET 2005 2. This machine also has another account user1 which is a guest account 3. I am running a program as Administrator, from this pr

  • C# Table Adapter Update Not Working 2008-11-29

    I am trying to serialize an object to a sql compact database. I am using VCS Express 2008. Every time I run a test to see if my data is sent to the database, nothing is in the database. My code: string inputForDB = null; QuizCategoryTableAdapter quiz

  • jquery .html does not work with script 2008-12-03

    $("#leaderBoard").html("<script2 language=\"javascript2\"> document.write('<scr'+'ipt language=\"javascript21.1\">alert(1)</scri'+'pt>'); </script2>".replace(/script2/gi, "script")); ie8 not wirking at all. FF3 is exucuting bu

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.376 (s). 11 q(s)