EDN Admin
Well-known member
I am trying to locate a specific paragraph in a docxs document.xml file
I can get it to work. I am trying to locate the "Document Title" element.
Code:
<div style="color:Black;background-color:White; <pre>
XElement root = XElement.Load(<span style="color:#A31515; "document.xml");
XNamespace aw = <span style="color:#A31515; "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
IEnumerable<XElement> address =
<span style="color:Blue; from el <span style="color:Blue; in root.Elements(aw + <span style="color:#A31515; "r")
<span style="color:Blue; where (<span style="color:Blue; string)el.Element(aw + <span style="color:#A31515; "t") == <span style="color:#A31515; "Document Title"
<span style="color:Blue; select el;
<span style="color:Blue; foreach (XElement el <span style="color:Blue; in address)
Console.WriteLine(el);
[/code]
Xml block. the file is too big to include all
<div style="color:Black;background-color:White; <pre>
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; p <span style="color:Red; w:rsidR<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 00C04B06<span style="color:Black; " <span style="color:Red; w:rsidRPr<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 007E7472<span style="color:Black; " <span style="color:Red; w:rsidRDefault<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 00C04B06<span style="color:Black; " <span style="color:Red; w:rsidP<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 007D07DF<span style="color:Black; "<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; pPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; pStyle <span style="color:Red; w:val<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Header<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; spacing <span style="color:Red; w:before<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 60<span style="color:Black; " <span style="color:Red; w:after<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 60<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rFonts <span style="color:Red; w:ascii<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:hAnsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:cs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; b <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; pPr<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; r <span style="color:Red; w:rsidRPr<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 007E7472<span style="color:Black; "<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rFonts <span style="color:Red; w:ascii<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:hAnsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:cs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; b <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; t<span style="color:Blue; >Document Title:<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; t<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; r<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; p<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; tc<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; tc<span style="color:Blue; >
[/code]
View the full article
I can get it to work. I am trying to locate the "Document Title" element.
Code:
<div style="color:Black;background-color:White; <pre>
XElement root = XElement.Load(<span style="color:#A31515; "document.xml");
XNamespace aw = <span style="color:#A31515; "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
IEnumerable<XElement> address =
<span style="color:Blue; from el <span style="color:Blue; in root.Elements(aw + <span style="color:#A31515; "r")
<span style="color:Blue; where (<span style="color:Blue; string)el.Element(aw + <span style="color:#A31515; "t") == <span style="color:#A31515; "Document Title"
<span style="color:Blue; select el;
<span style="color:Blue; foreach (XElement el <span style="color:Blue; in address)
Console.WriteLine(el);
[/code]
Xml block. the file is too big to include all
<div style="color:Black;background-color:White; <pre>
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; p <span style="color:Red; w:rsidR<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 00C04B06<span style="color:Black; " <span style="color:Red; w:rsidRPr<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 007E7472<span style="color:Black; " <span style="color:Red; w:rsidRDefault<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 00C04B06<span style="color:Black; " <span style="color:Red; w:rsidP<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 007D07DF<span style="color:Black; "<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; pPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; pStyle <span style="color:Red; w:val<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Header<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; spacing <span style="color:Red; w:before<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 60<span style="color:Black; " <span style="color:Red; w:after<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 60<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rFonts <span style="color:Red; w:ascii<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:hAnsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:cs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; b <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; pPr<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; r <span style="color:Red; w:rsidRPr<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 007E7472<span style="color:Black; "<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rFonts <span style="color:Red; w:ascii<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:hAnsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Red; w:cs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Arial<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; b <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; rPr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; t<span style="color:Blue; >Document Title:<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; t<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; r<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; p<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; tc<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; w<span style="color:Blue; :<span style="color:#A31515; tc<span style="color:Blue; >
[/code]
View the full article