üzerinde desteklenmiyor XML'yi ayrıştırmaya çalışıyorum ve XMLreader kullanarak tüm bilgileri almayı deniyorum. Bir nedenden ötürü başlığı hatayı atıyor. İşte xml geçerli:ReadElementContentAsString yöntemi, node type Text
<?xml version="1.0" encoding="utf-8" ?>
<queries>
<selectparent table="Associates">"SELECT * FROM @table"</selectparent>
<selectchild table="VehicleContract">"SELECT * FROM @table"</selectchild>
<addchild table="VehicleContract" read="contractId, regNr, assoc_id, percentage, vehicleType, trailerNr">"INSERT into @table (contractId, regNr, assoc_id, percentage, vehicleType, trailerNr) VALUES (@id, @reg, @assort, @perc, @type, @trailer)"</addchild>
<updatechild table="VehicleContract" read="contractId, regNr, assoc_id, percentage, vehicleType, trailerNr">"UPDATE @table SET [email protected], [email protected], [email protected], [email protected], [email protected] WHERE [email protected]"</updatechild>
<removechild table="VehicleContract" read="id">"DELETE from @table WHERE [email protected]"</removechild>
</queries>
Ve yöntemi:
public string selectParent, selectChildren, addChildren, updateChildren, removeChildren;
public string[] addParams, updateParams, removeParams;
XmlTextReader reader = new XmlTextReader(base.Path);
reader.WhitespaceHandling = WhitespaceHandling.None;
reader.Read();
reader.Read();
reader.Read();
selectParent = reader.ReadElementContentAsString();
reader.Read();
selectChildren = reader.ReadElementContentAsString();
addParams = reader.GetAttribute("read").Split(',');
addChildren = reader.ReadElementContentAsString();
updateParams = reader.GetAttribute("read").Split(',');
updateChildren = reader.ReadElementContentAsString();
removeParams = reader.GetAttribute("read").Split(',');
removeChildren = reader.ReadElementContentAsString();
bu hat üzerinde hata alıyorum:
selectParent = reader.ReadElementContentAsString
sorunu ne?
reader.Read()
eklemeye devam ettim çünkü aynı hatayı ancak farklı düğüm tiplerinde tutmaya devam ettim.
Bildiğim kadarıyla, tablo özniteliği sorgudan @table'ın yerini almalı ... ama bir şey doğru değil. Herhangi bir fikir?
kullanmak. Kodunuzu XML olarak bir dize olarak eklediğimde ve yeni MemoryStream (Encoding.UTF8.GetBytes (xml)) 'yi kullanarak okuyucuya yüklediğimde kodunuz benim için çalışır. Ayrıca, kodunuzu ayıklayabilir ve 'reader.NodeType' ve' reader.Name''e bakabilirseniz, bu dosyada nerede olduğunuzu söyleyecektir. –
Tüm yolu kullandım ve hata ayıklayıcısında, beni xml'ye götürür. Bu satıra geldiğimde,> "SELECT * FROM @table" gösterir ve ardından şu hatayı atar:/ – Mocktheduck