Attribute in Tag XML C# -
i'm generating xml file using c#, file exist, need set attribute inside of tag..for exemple:
<infdeclaracaoprestacaoservico id="id41503"> in file "id" stay between tags
<infdeclaracaoprestacaoservico> id="id41503" <rps> my tags create this:
xmlnode xmlnodeidentificacaorps = xmldoc.createelement("infdeclaracaoservico", "identificacaorps", null); xmlnodeidentificacaorps.innertext = ""; xmlnodeinfdeclaracaoservico.appendchild(xmlnodeidentificacaorps); i think in place of "innertext" need put attribute..but have no idea how can work! appreciate
you can add attribute follows:
xmlattribute attr = xmldoc.createattribute("id"); attr.value = "id41503"; xmlnodeidentificacaorps.attributes.append(attr); attributes resides within xml elements tag, if place under element(as nested), have use:
xmlnodeidentificacaorps.innertext = "id='id41503'";
Comments
Post a Comment