Клубове Дир.бг
powered by diri.bg
търси в Клубове diri.bg Разширено търсене

Вход
Име
Парола

Клубове
Dir.bg
Взаимопомощ
Горещи теми
Компютри и Интернет
Контакти
Култура и изкуство
Мнения
Наука
Политика, Свят
Спорт
Техника
Градове
Религия и мистика
Фен клубове
Хоби, Развлечения
Общества
Я, архивите са живи
Клубове Дирене Регистрация Кой е тук Въпроси Списък Купувам / Продавам 07:12 25.04.24 
Клубове/ Компютри и Интернет / XML Пълен преглед*
Информация за клуба
Тема Re: може [re: ghs]
АвторЛaмep (Нерегистриран) 
Публикувано14.09.06 12:51  



благодаря ти за отзивчивостта
ето кода:
<%
dim xmlDoc
dim rootEl,fieldName,fieldValue,attID
dim p,i

'Do not stop if an error occurs
On Error Resume Next

Set xmlDoc = server.CreateObject("Microsoft.XMLDOM")
xmlDoc.preserveWhiteSpace=true

'Create a root element and append it to the document
Set rootEl = xmlDoc.createElement("customer")
xmlDoc.appendChild rootEl

'Loop through the form collection
for i = 1 To Request.Form.Count
'Eliminate button elementsin the form
if instr(1,Request.Form.Key(i),"btn_")=0 then
'Create a field and a value element, and an id attribute
Set fieldName = xmlDoc.createElement("field")
Set fieldValue = xmlDoc.createElement("value")
Set attID = xmlDoc.createAttribute("id")
'Set the value of the id attribute equal to the name of
'the current form field
attID.Text = Request.Form.Key(i)
'Append the id attribute to the field element
fieldName.setAttributeNode attID
'Set the value of the value element equal to
'the value of the current form field
fieldValue.Text = Request.Form(i)
'Append the field element as a child of the root element
rootEl.appendChild fieldName
'Append the value element as a child of the field element
fieldName.appendChild fieldValue
end if
next

'Add an XML processing instruction
'and insert it before the root element
Set p = xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,xmlDoc.childNodes(0)

'Save the XML file
xmlDoc.save "c:Customer.xml"

'Release all object references
set xmlDoc=nothing
set rootEl=nothing
set fieldName=nothing
set fieldValue=nothing
set attID=nothing
set p=nothing

'Test to see if an error occurred
if err.number<>0 then
response.write("Error: No information saved.")
else
response.write("Your information has been saved.")
end if
%>
Резултатът:
<?xml version="1.0" ?>
<customer>
<field id="firstName">
<value>Hege</value>
</field>
<field id="lastName">
<value>Refsnes</value>
</field>
<field id="country">
<value>Norway</value>
</field>
<field id="email">
<value>mymail@myaddress.com</value>
</field>
а ето как искам аз да се получи:
<?xml version="1.0" ?>
<customer>
<firstName>
Hege
</firstName>
<lastName>
Refsnes
</lastName>
<country>
Norway
</country>
<email>
mymail@myaddress.com
</email>
</customer>



Цялата тема
ТемаАвторПубликувано
* Глупав въпрос Лaмep   04.09.06 17:45
. * може ghs   05.09.06 11:47
. * Re: може лaмep   07.09.06 12:12
. * Re: може ghs   07.09.06 20:12
. * Re: може лaмep   11.09.06 11:58
. * Re: може ghs   11.09.06 18:35
. * Re: може лaмep   13.09.06 15:25
. * Re: може ghs   14.09.06 10:24
. * Re: може Лaмep   14.09.06 12:51
. * Re: може Лaмep   19.09.06 12:05
. * Re: може ghs   19.09.06 12:46
. * Re: може Лaмep   19.09.06 13:30
. * Re: може ghs   20.09.06 11:30
. * Re: може Лaмep   20.09.06 13:23
. * Re: може ghs   20.09.06 14:19
. * Re: може Лaмep   21.09.06 16:55
. * Re: може Лaмep   26.09.06 10:53
. * Re: може ghs   26.09.06 11:08
. * Re: може _croesus   04.10.06 11:52
Клуб :  


Clubs.dir.bg е форум за дискусии. Dir.bg не носи отговорност за съдържанието и достоверността на публикуваните в дискусиите материали.

Никаква част от съдържанието на тази страница не може да бъде репродуцирана, записвана или предавана под каквато и да е форма или по какъвто и да е повод без писменото съгласие на Dir.bg
За Забележки, коментари и предложения ползвайте формата за Обратна връзка | Мобилна версия | Потребителско споразумение
© 2006-2024 Dir.bg Всички права запазени.