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

Invalid character in name - buildObject #639

Open
oscar-developer opened this issue Mar 11, 2022 · 2 comments
Open

Invalid character in name - buildObject #639

oscar-developer opened this issue Mar 11, 2022 · 2 comments

Comments

@oscar-developer
Copy link

oscar-developer commented Mar 11, 2022

Hi Leonidas,
I have a problem when trying to convert a json to xml.
the "Invoice" tag needs to be an array since I will dynamically add more of the same elements.

var JsonFact = {
'Invoice':[{
'$' : {
"listURI":"urn:pe:gob:sunat:cpe:see:catalogos:catalogo01",
"listName":"Tipo de Documento",
"listAgencyName": "PE:SUNAT",
"listID":"0101"
}
},
"cbc:item":"1",
"cbc:item":"2",
"cbc:item":"3"
]
};
//JsonFact =JsonFact.Invoice.push({"cbc:item":"4"});
//JsonFact =JsonFact.Invoice.push({"cbc:item":"5"});

var builder = new xml2js.Builder( { headless: false, renderOpts: { pretty: true } ,xmldec: {version: "1.0"}});
var xml = builder.buildObject(JsonFact);
then throw the message "Invalid character in name --> $ "

Could you please guide me how to solve it, thanks Leonidas.

@oscar-developer
Copy link
Author

Solucionado, primero se agregan todas las etiquetas que se necesitan y se agregan poco a poco las vacias[].

@satyajitnayk
Copy link

satyajitnayk commented Nov 21, 2023

Translation: Solved, first all the tags that are needed are added and the empty ones[] are added little by little.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants