Home > Back-end >  The XML value problem?
The XML value problem?

Time:10-30

<? The XML version="1.0"?>








Want to get the following results: from the above

88157960000084632422
88157960000061325274
88157960000060866605
88157960000091704302

CodePudding user response:

Delphi reads the XML is not difficult, to learn:
http://peirenlei.iteye.com/blog/305030

CodePudding user response:

There is a call NativeXML control

CodePudding user response:

Worth learning!

CodePudding user response:

With Internet page inside the XMLDocument controls, baidu once there are many examples of specific usage
Or direct interception of string

CodePudding user response:

For example, or demonstration

CodePudding user response:

I also want to know,

CodePudding user response:

 
Const
S=
'& lt; ? The XML version="1.0"?> '
+ '& lt; The Document XMLNS: xsi="http://www.w3.org/2001/XMLSchema-instance" XMLNS: XSD="http://www.w3.org/2001"
+ '/XMLSchema "SN=" 300805 "License=" 1 "Version=" 2.2.1 "& gt; '
+ '& lt; Events> '
+ '& lt; The Event Name="SalesWareHouseOut MainAction"="WareHouseOut & gt;" '
+ '& lt; DataField> '
+ '& lt; The Data Code="88157960000084632422" CorpOrderID="0319781" the Actor="1" ActDate="2012-07-05 14:47:56"/& gt; '
+ '& lt; The Data Code="88157960000061325274" CorpOrderID="0319781" the Actor="1" ActDate="2012-07-05 14:47:56"/& gt; '
+ '& lt; The Data Code="88157960000060866605" CorpOrderID="0319781" the Actor="1" ActDate="2012-07-05 14:47:56"/& gt; '
+ '& lt; The Data Code="88157960000091704302" CorpOrderID="0319781" the Actor="1" ActDate="2012-07-05 14:47:56"/& gt; '
+ '& lt;/DataField> '
+ '& lt;/Event> '
+ '& lt;/Events> '
+ '& lt;/Document> ';

The function GetXmldata (Source: string; Sl: TStringlist) : Boolean;
Const head='& lt; The Data Code="';
Var I: integer;
The begin
Result:=false;
I:=pos (head, Source);
If i<1 then the exit;
Repeat
I:=I + length (the head);
Sl. Append (copy (20) Source, I,);
Delete (Source, 1, I);
I:=pos (head, Source);
Until i<1;
Result:=true;
end;

Procedure TForm1. Button1Click (Sender: TObject);
Var sl: TStringlist;
The begin
Sl:=TStringlist. Create;
Then the if GetXmldata (s, sl)
Showmessage (sl) Text);
Sl. Free;
end;

CodePudding user response:

refer to 7th floor gzzai response:
Delphi/Pascal code? 123456789101112131415161718192021222324252627282930313233343536373839404142 const s='& lt; ? The XML version="1.0"?> '+' & lt; The Document XMLNS: xsi="HTTP://http://www.w3.org/2001/XMLSchema-i...

You're so talented,,,

CodePudding user response:

Dizzy, the original poster not limited by what means, even friends also mentioned 4 floor can use the method of intercepting? The code I also verified...

CodePudding user response:

First of all, thank you for guangzhou tsai! But your method can only solve the current file, if there are multiple contains the above format files folder, can't meet, you imagine... I met with Daniel to the resolution,

CodePudding user response:

Use NativeXML most simple, online with this control, is pas files, can use the direct introduction of engineering, the operation is very simple,
Can directly find the node Data Code, and then read the content,
Var
XMLDoc: TNativeXML;//NativeXML
RootNode: TXMLNode;//define the root node
CNode: TXMLNode;//Data node
The begin
//instantiate the action class
XMLDoc:=TNativeXML. Create;
Try
XMLDoc. LoadFromFile (XmlPath);//load the XML file (full path)
RootNode:=XMLDoc. Root;//get the root of the XML node
//began to search the Data from the root node
CNode:=RootNode FindNode (' Data ');//here can find multiple RootNode. FindNodes (' Data 'TList);
If cNode & lt;> Nil then
ShowMessage (cNode. ReadAttributeString (" Code "));
The finally
XMLDoc. Free;
end;
end;

CodePudding user response:

11 floor, ice your ideas are right, but you actually tested? The above code you still can't completely solve the problem?

CodePudding user response:

Through the node

The Data Code

Read the data,

CodePudding user response:

I haven't tested the code, to visit as I previously written procedures, just provide a train of thought, I just read a node

CodePudding user response:

Ha ha, many methods, but also can be a text file to read and write,

CodePudding user response:

XMLDocument, look at the one thousand blog

CodePudding user response:

CodePudding user response:

xmldocmentnullnullnullnullnullnullnullnullnull
  • Related