Home > database >  How to read through the Msxml in PB8 XML files on the WEB
How to read through the Msxml in PB8 XML files on the WEB

Time:10-01

And now have a project to the customer's mail system do interface
Both sides to discuss sure to process the data by means of XML + HTTP communication
1. Each other on the web to send an XML file, tell me a email address
2. We read email address information in an XML file
3. We put this email address corresponding to the client code and customer name sent via the form of XML to the web



Now I found a piece of code on step 3, the HTML code is as follows, hope expert guidance,
OLEObject dom, HTTP
String Http_Name, result

Http_Name="http://www.test.com/tims/servlet/WebServerServlet"

Dom=CREATE OLEObject
HTTP=CREATE OLEObject
//messagebox debugging to see if success
Messagebox (' HTTP 'HTTP. ConnectToNewObject (" Msxml2. XMLHTTP "))
Messagebox (' dom, dom. ConnectToNewObject (" Msxml2. DOMDocument "))

The dom. The Load (" D: \ test \ test XML ")
HTTP. Open (" POST ", Http_Name, TRUE)//if TRUE here to switch to False, while part of the code can not
HTTP. Send (dom) XML)//if found to have the code, please use HTTP. Send (dom)
The do While HTTP. ReadyState & lt;> 4//query state, delay
The yield ()
Loop

Result=HTTP. The responseText//this test! You don't write
Messagebox (" result ", result)



Now about the step 1, I online, a program is as follows:
//reads the XML file
OleObject loo_dom, loo_node
Int li_Result
String as_xmlfile, as_value

Loo_dom=CREATE OleObject

Li_Result=loo_DOM. ConnectToNewObject (' Msxml2. DOMDocument ')
IF li_Result & lt; 0 THEN
MessageBox (' error: ', 'I'm sorry, but the DOM to create failure! ')
RETURN
END the IF

Loo_dom. Async=false

As_xmlfile='D: \ test \ down \ test XML'
Loo_dom. Load (as_xmlfile)

//loo_node=loo_dom. SelectNodes ("//Data [@ rk_id='1'] ")
Loo_node=loo_dom. SelectNodes (' http://www.test.com/tims/servlet/WebServerServlet//QueryCustomer ')

If (loo_node. Length=0) THEN
Messagebox (' error: ', "there is no data that you want!" )
Return
The ELSE
as_value=https://bbs.csdn.net/topics/loo_node.childNodes [1]. The text
END the IF

Messagebox (' as_value 'as_value)
Destroy loo_dom
Destroy loo_node

RETURN

Run loo_node=loo_dom. SelectNodes (' http://www.test.com/tims/servlet/WebServerServlet//QueryCustomer ') this sentence, prompt "Error calling external object function selectNodes... "


Please everybody take more advice, thank you!

CodePudding user response:

File made, built a corresponding template of dw pour good,

CodePudding user response:

reference 1st floor AFIC response:
file made, built a corresponding template combine dw,


Now the problem is there is no way to get the XML file
Hurry!
Masters to help you

CodePudding user response:

Online waiting for

CodePudding user response:

Is not I will not give points
But I have no points
Also please master to give directions

CodePudding user response:

You can get XML with PB INET, why should use what OLE

CodePudding user response:

SelectNodes (" data ") to a child node under the root node object is stored in the object returned in the array,

For example:
& lt; Data>
& lt; Row> & lt;/row>
& lt; Row> & lt;/row>
& lt;/data>

Can therefore be selectNodes (" data "). The.childnodes [1]. The text visiting asked node row
Under the.childnodes refers to the parent a child of the node

Must first determine whether the load is successful, the second is a look at the load after a successful have the nodes in the XML document & lt; http://www.test.com/tims/servlet/WebServerServlet//QueryCustomer>

CodePudding user response:

For example:
Var oNodes=selectNodes (" data/row ")
If (oNodes. Length<0) return
For (var item=0; ItemONodes [items] selectsinglenode (" dw "). The getattribute (" name ")//that will be the first line of the name value
}
//the getattribute refers to get a node of a certain attribute

//XML file content
& lt; Data>
& lt; Row> & lt; Dw name="" & gt; & lt;/dw> & lt;/row>
& lt; Row> & lt; Dw name="" & gt; & lt;/dw> & lt;/row>
& lt;/data>

CodePudding user response:

Or add a stored procedure, the incoming XML storage path,

/* for XML transformation under */
DECLARE @ FileName varchar (255), @ ExecCmd varchar (255)

DECLARE @ y INT, @ INT x

DECLARE @ FileContents VARCHAR (8000)

The CREATE TABLE # tempXML (PK INT the NOT NULL IDENTITY (1, 1), ThisLine VARCHAR (255))

SET @ FileName='e: \ test XML'//XML file path

SET @ ExecCmd='type' + @ FileName

The SET @ FileContents='

INSERT INTO # tempXML EXEC master. The dbo. Arbitrary @ ExecCmd

SELECT @ y=the count (*) from # tempXML

The SET @ x=0

WHILE @ x & lt;> @ y

The BEGIN

The SET @ x=@ x + 1

SELECT @ FileContents=@ FileContents + ThisLine the from # tempXML WHERE PK=@ x

END

DROP TABLE # tempXML


/* below to read XML data, is the root node in the openxml while behind with the corresponding is the child node */
DECLARE @ idoc int
The EXEC sp_xml_preparedocument @ idoc OUTPUT, @ FileContents

//output XML data content
SELECT *
The FROM OPENXML (@ idoc, '/result/item, 1)
WITH ([name] varchar (10),
The value varchar (20))


The EXEC sp_xml_removedocument @ idoc

/*
//e: \ test. The XML file content
& lt; The result sum="date"="" & gt;
& lt; The item name="SUM02" value="https://bbs.csdn.net/topics/12"/& gt;
& lt; nullnullnullnullnullnullnullnullnullnull
  • Related