Hej Greystate
Når jeg indsætter din kode får jeg fejl i de to linier med oNode.setAttribute
oNode.setAttribute("unitCode", "kasse")
oNode.setAttribute("unitCodeListAgencyID", "n/a")
________________________________________________________
Jeg prøver lige at uddybe mit problem.
min kode ser således ud
Private Sub TestXml()
Dim xmlDoc As New DOMDocument
Dim root As IXMLDOMElement
Dim newNode As Object
Dim success As Boolean
xmlDoc.async = False
success = xmlDoc.Load(App.Path & "\testmyXMLfile.xml")
If success = True Then
Set root = xmlDoc.documentElement
Set newNode = xmlDoc.createElement("com:InvoiceLine")
newNode.appendChild xmlDoc.createElement("com:ID")
newNode.childNodes(0).Text = "3"
newNode.appendChild xmlDoc.createElement("com:InvoicedQuantity")'<= Mit problem er HER
newNode.childNodes(1).Text = "30"
newNode.appendChild xmlDoc.createElement("com:LineExtensionAmount")
newNode.childNodes(2).Text = "3000.00"
newNode.appendChild xmlDoc.createElement("com:Item")
newNode.childNodes(3).appendChild xmlDoc.createElement("com:ID")
newNode.childNodes(3).childNodes(0).Text = "0000"
newNode.childNodes(3).appendChild xmlDoc.createElement("com:Description")
newNode.childNodes(3).childNodes(1).Text = "Tekst"
newNode.appendChild xmlDoc.createElement("com:BasePrice")
newNode.childNodes(4).appendChild xmlDoc.createElement("com:PriceAmount") 'stykpris
newNode.childNodes(4).childNodes(0).Text = "100.00"
xmlDoc.documentElement.appendChild newNode.cloneNode(True)
DisplayNode root
End If
xmlDoc.Save (App.Path & "\testmyXMLfile.xml")
Set root = Nothing
Set newNode = Nothing
Set xmlDoc = Nothing
End Sub
hvor DisplayNode er en "Private Sub" der løber min XML fil igennem og tilretter værdier, jeg ønsker nu at indsætte de nodes der er vist i min kode, men får problemer når jeg skal angive attributterne.
Min XML fil ser således ud.
<?xml version="1.0" encoding="UTF-8" ?>
<Invoice xmlns="
http://rep.oio.dk/ubl/xml/schemas/0p71/pie/" xmlns:com="
http://rep.oio.dk/ubl/xml/schemas/0p71/common/" xmlns:main="
http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://rep.oio.dk/ubl/xml/schemas/0p71/pie/ http://rep.oio.dk/ubl/xml/schemas/0p71/pie/pieStrict.xsd"> <com:ID>2296</com:ID>
<com:IssueDate>2004-10-13</com:IssueDate>
<com:TypeCode>PIE</com:TypeCode>
<main:InvoiceCurrencyCode>DKK</main:InvoiceCurrencyCode>
<com:BuyersReferenceID>5798000416642</com:BuyersReferenceID>
<com:ReferencedOrder>
<com:BuyersOrderID>M23-453</com:BuyersOrderID>
<com:SellersOrderID />
<com:IssueDate>2004-10-01</com:IssueDate>
</com:ReferencedOrder>
<com:BuyerParty>
<com:ID schemeID="CVR">12312312</com:ID>
<com:AccountCode>3070</com:AccountCode>
<com:PartyName>
<com:Name>IT- og Telestyrelsen</com:Name>
</com:PartyName>
<com:Address>
<com:ID>Fakturering</com:ID>
<com:Street>Holsteinsgade</com:Street>
<com:HouseNumber>63</com:HouseNumber>
<com:CityName>Koebenhavn</com:CityName>
<com:PostalZone>2100</com:PostalZone>
<com:Country>
<com:Code>DK</com:Code>
</com:Country>
</com:Address>
<com:BuyerContact>
<com:ID>rak@itst.dk</com:ID>
</com:BuyerContact>
</com:BuyerParty>
<com:SellerParty>
<com:ID schemeID="CVR">26440858</com:ID>
<com:PartyName>
<com:Name>JBN-Design</com:Name>
</com:PartyName>
<com:Address>
<com:ID>Betaling</com:ID>
<com:Street>Soevang Alle</com:Street>
<com:HouseNumber>29 st.</com:HouseNumber>
<com:CityName>Kastrup</com:CityName>
<com:PostalZone>2770</com:PostalZone>
</com:Address>
<com:PartyTaxScheme>
<com:CompanyTaxID schemeID="CVR">26440858</com:CompanyTaxID>
</com:PartyTaxScheme>
</com:SellerParty>
<com:PaymentMeans>
<com:TypeCodeID>null</com:TypeCodeID>
<com:PaymentDueDate>2004-11-01</com:PaymentDueDate>
<com:PaymentChannelCode>KONTOOVERFOERSEL</com:PaymentChannelCode>
<com:PayeeFinancialAccount>
<com:ID>4613076980</com:ID>
<com:TypeCode>BANK</com:TypeCode>
<com:FiBranch>
<com:ID>0290</com:ID>
<com:FinancialInstitution>
<com:ID>null</com:ID>
<com:Name>BG-Bank</com:Name>
</com:FinancialInstitution>
</com:FiBranch>
</com:PayeeFinancialAccount>
<com:PaymentAdvice>
<com:AccountToAccount>
<com:PayerNote>2296</com:PayerNote>
</com:AccountToAccount>
</com:PaymentAdvice>
</com:PaymentMeans>
<com:TaxTotal>
<com:TaxTypeCode>VAT</com:TaxTypeCode>
<com:TaxAmounts>
<com:TaxableAmount currencyID="DKK">5300.00</com:TaxableAmount>
<com:TaxAmount currencyID="DKK">1325.00</com:TaxAmount>
</com:TaxAmounts>
<com:CategoryTotal>
<com:RateCategoryCodeID>VAT</com:RateCategoryCodeID>
<com:RatePercentNumeric>25</com:RatePercentNumeric>
<com:TaxAmounts>
<com:TaxableAmount currencyID="DKK">5300.00</com:TaxableAmount>
<com:TaxAmount currencyID="DKK">1325.00</com:TaxAmount>
</com:TaxAmounts>
</com:CategoryTotal>
</com:TaxTotal>
<com:LegalTotals>
<com:LineExtensionTotalAmount currencyID="DKK">5300.00</com:LineExtensionTotalAmount>
<com:ToBePaidTotalAmount currencyID="DKK">6625</com:ToBePaidTotalAmount>
</com:LegalTotals>
</Invoice>
Hilsen JBjerre